Advertisement
icatalin

noname3 infoarena

Dec 17th, 2014
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.69 KB | None | 0 0
  1. #include<fstream>
  2. using namespace std;
  3. ifstream f("noname3.in");
  4. ofstream g("noname3.out");
  5. int main ()
  6. {
  7.     int n,s,x,k,r,pr,i;
  8.     f>>n>>s;
  9.     if(n%2==1)
  10.     {
  11.         k=n/2;
  12.         x=s/n;
  13.         r=s%n;
  14.         pr=x-k;
  15.         for(i=1;i<=n;i++)
  16.         {
  17.             if(i>=(n-r+1))
  18.                 g<<pr+1<<" ";
  19.             else
  20.                 g<<pr<<" ";
  21.             pr++;
  22.         }
  23.     }
  24.     else
  25.         {
  26.         k=n/2;
  27.         s=s-k;
  28.         x=s/n;
  29.         r=s%n;
  30.         pr=x-k+1;
  31.         for(i=1;i<=n;i++)
  32.         {
  33.             if(i>=(n-r+1))
  34.                 g<<pr+1<<" ";
  35.             else
  36.                 g<<pr<<" ";
  37.             pr++;
  38.         }
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement