Advertisement
Guest User

Untitled

a guest
Jul 7th, 2016
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. typedef long long LL;
  6.  
  7. int main()
  8. {
  9. // freopen("in.txt","r",stdin);
  10. // freopen("outta.txt","w",stdout);
  11. int i, j, cs, test, t, r, R, T, n;
  12. cin >> test;
  13. for(cs = 1; cs<=test; cs++)
  14. {
  15. cin >> R >> T >> n;
  16. LL ans = 0;
  17. for(r = 1; r<=R; r++)
  18. {
  19. for(t = 1; t<=T; t++)
  20. {
  21. ///check if starting after r rounds with t points is a winning position
  22.  
  23. /// since at least one point is achieved every round, t < r is not possible
  24. if(t < r)
  25. continue;
  26. /// since at most n points can be achieved every round, t > r*n is not possible
  27. if(t > r*n)
  28. continue;
  29. /// since at least one point is achieved every round, one will at least achieve
  30. /// (R-r) points in the next (R-r) rounds. if( (T < (R-r)+t) then surely he will
  31. /// achieve more points than T.
  32. if(T < (R-r+t) )
  33. continue;
  34.  
  35. /// since at most n points can be achieved every round, one will at most achieve (R-r)*n
  36. /// points in the next (R-r) rounds. if( T > (R-r)*n + t), then surely he will achieve
  37. /// less points than T.
  38. if(T> (R-r)*n + t)
  39. continue;
  40.  
  41. /// if all of the above conditions are false, then this must be a winning state.
  42. ans++;
  43. }
  44. }
  45. printf("Case %d: %lld\n",cs,ans);
  46. }
  47. return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement