Advertisement
Pedromaia26

Exercício kattis

Sep 17th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main(){
  4.    
  5.     int num, t, s;
  6.    
  7.     t = 0;
  8.    
  9.     s = 0;
  10.    
  11.     while(scanf("%d",&num)!=EOF){
  12.        
  13.         t++;
  14.    
  15.         if (num % t == 0){
  16.            
  17.             s += t;
  18.            
  19.         }
  20.        
  21.         if (s == num){
  22.            
  23.             printf("%d perfect",s);
  24.            
  25.         }
  26.        
  27.         else if ((s - num < 2 ) || (s - num > -2)){
  28.            
  29.             printf("%d almost perfect",s);
  30.            
  31.         }
  32.        
  33.         else {
  34.            
  35.             printf("%d not perfect",s);
  36.            
  37.         }
  38.        
  39.        
  40.     }
  41.    
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement