Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- typedef long long LL;
- int main()
- {
- // freopen("in.txt","r",stdin);
- // freopen("outta.txt","w",stdout);
- int i, j, cs, test, t, r, R, T, n;
- cin >> test;
- for(cs = 1; cs<=test; cs++)
- {
- cin >> R >> T >> n;
- LL ans = 0;
- for(r = 1; r<=R; r++)
- {
- for(t = 1; t<=T; t++)
- {
- ///check if starting after r rounds with t points is a winning position
- /// since at least one point is achieved every round, t < r is not possible
- if(t < r)
- continue;
- /// since at most n points can be achieved every round, t > r*n is not possible
- if(t > r*n)
- continue;
- /// since at least one point is achieved every round, one will at least achieve
- /// (R-r) points in the next (R-r) rounds. if( (T < (R-r)+t) then surely he will
- /// achieve more points than T.
- if(T < (R-r+t) )
- continue;
- /// since at most n points can be achieved every round, one will at most achieve (R-r)*n
- /// points in the next (R-r) rounds. if( T > (R-r)*n + t), then surely he will achieve
- /// less points than T.
- if(T> (R-r)*n + t)
- continue;
- /// if all of the above conditions are false, then this must be a winning state.
- ans++;
- }
- }
- printf("Case %d: %lld\n",cs,ans);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement