Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- #define InFile "sotron.in"
- #define OutFile "sotron.out"
- using namespace std;
- int main()
- {
- int p,n;
- long long m,C,s;
- ifstream f(InFile);
- f>>p>>n>>m;
- f.close();
- ofstream g(OutFile);
- if(p==1)
- g<<1ULL*n*(n+1)/2<<'\n';
- else
- {
- int i,r,c=0;
- s=0;
- for(i=n;i;i-=2)
- {
- ++c;
- s+=2*i-1;
- if(s>=m)
- break;
- }
- C=s-i+1;
- if(m>C)
- r=n-c+1,c=c+m-C;
- else
- r=(n-c+1)-(C-m);
- g<<r<<' '<<c<<'\n';
- }
- g.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement