Advertisement
Anon2005

tbile

Sep 29th, 2022
956
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.56 KB | None | 0 0
  1. #include <fstream>
  2. using namespace std;
  3. ifstream in("tbile.in");
  4. ofstream out("tbile.out");
  5. int x[100001],y[100001];
  6. int main()
  7. {
  8.     int p,n,m,i,j;
  9.     in>>p>>n>>m;
  10.     x[1]=1;
  11.     y[1]=2;
  12.     x[2]=3;
  13.     y[2]=4;
  14.     j=3;
  15.     for(i=3;;i++)
  16.     {
  17.         x[i]=x[i-1]+y[i-1];
  18.         y[i]=y[i-1]+1;
  19.         if(y[i]==x[j])
  20.         {
  21.             j++;
  22.             y[i]++;
  23.         }
  24.         if(x[i]>n)
  25.             break;
  26.     }
  27.     i--;
  28.     //bilele x[1],x[2],...,x[i] formeaza sirul x
  29.     if(p==1)
  30.         out<<(n-i+m-1)/m<<" "<<n-i;
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement