Advertisement
Josif_tepe

Untitled

Nov 5th, 2023
745
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.86 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <ctype.h>
  5.  
  6.  
  7. int main(int argc, const char * argv[]) {
  8.     int n;
  9.     scanf("%d", &n);
  10.    
  11.     int maks_zbir = 0;
  12.     int broj;
  13.     for(int i = n - 1; i >= 0; i--) {
  14.         int zbir = 0;
  15.         for(int j = 1; j <= i; j++) {
  16.             if(i % j == 0) {
  17.                 zbir += j;
  18.             }
  19.         }
  20.        
  21.         if(maks_zbir < zbir) {
  22.             maks_zbir = zbir;
  23.             broj = i;
  24.         }
  25.     }
  26.     int brojac = 0;
  27.     for(int i = n - 1; i >= 0; i--) {
  28.         int zbir = 0;
  29.         for(int j = 1; j <= i; j++) {
  30.             if(i % j == 0) {
  31.                 zbir += j;
  32.             }
  33.         }
  34.        
  35.         if(maks_zbir == zbir) {
  36.             brojac++;
  37.         }
  38.     }
  39.    
  40.     printf("%d %d %d\n", broj, maks_zbir, brojac);
  41.    
  42.     return 0;
  43. }
  44.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement