Advertisement
bappi2097

G - Left Stack Game

Aug 19th, 2019
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.83 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. typedef unsigned long long ull;
  4. void inOut()
  5. {
  6.     ios_base::sync_with_stdio(false);
  7.     cin.tie(NULL);
  8.     #ifndef ONLINE_JUDGE
  9.     freopen("input.txt","r",stdin);
  10.     #endif // ONLINE_JUDGE
  11. }
  12. int main()
  13. {
  14.     inOut();
  15.     ull m,ar[3];
  16.     cin>>m>>ar[0]>>ar[1]>>ar[2];
  17.     ull n=0;
  18.     for(int i=0;i<3;i++)
  19.     {
  20.         if(ar[i]<m && i<2)
  21.         {
  22.             ar[i+1]+=ar[i]%m;
  23.             continue;
  24.         }
  25.         else if(i<2)
  26.         {
  27.             n+=ar[i]/m;
  28.             if(ar[i]%m!=0 && i<2)ar[i+1]+=ar[i]%m;
  29.             else if(ar[i]%m!=0 && i==2)n++;
  30.         }
  31.         else
  32.         {
  33.             if(ar[i]>=m)n+=ar[i]/m;
  34.             if(ar[i]%m!=0)n++;
  35.         }
  36.     }
  37.     if(n%2==1)cout<<"Tomaz"<<endl;
  38.     else cout<<"Danftito"<<endl;
  39.     return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement