Advertisement
Guest User

C. New Year and the Sphere Transmission

a guest
Aug 19th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.53 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int x = 2, n, i, S = 0, copie, m;
  8.     cin >> n;
  9.     copie = (n * (n + 1)) / 2;
  10.     cout << copie << " ";
  11.     for(i = 2; i < n - 1; i++){
  12.         S = 1;
  13.         m = 1;
  14.         m = m + x;
  15.         while( m != 1 ){
  16.             S += m;
  17.             m += x;
  18.             if( m > n ){
  19.                 m = m - n;
  20.             }
  21.         }
  22.         x++;
  23.         if( S < copie ){
  24.             cout << S << " ";
  25.             copie = S;
  26.         }
  27.     }
  28.     cout << 1;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement