Submission #2645

#TimeUsernameProblemLanguageResultExecution timeMemory
2645tncks0121새로운 달력 (GCJ12KOR_calendar)C++98
25 / 25
0 ms1676 KiB
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> #include <assert.h> #include <memory.h> #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long llu; typedef double lf; typedef long double llf; int TC, TCC; ll A; int B, C; bool used[200]; ll sum[200]; int main() { int i, j; scanf("%d", &TC); while(++TCC <= TC) { memset(used, 0, sizeof used); memset(sum, 0, sizeof sum); scanf("%lld%d%d", &A, &B, &C); int t = C-1; int l = 0; for(l = 0; l <= C; l++) { int e = (t + B) % C; if(used[e]) { --l; break; } used[e] = true; if(l > 0) sum[l] = sum[l-1] + (ll)ceil((double)(t+B+1)/C); else sum[l] = (ll)ceil((double)B/C); t = e; } ll res = 0; res = sum[l] * (A / (l+1)); if(A % (l+1) > 0) res += sum[A % (l+1) - 1]; printf("Case #%d: %lld\n", TCC, res); /* for(i = 0; i <= l; i++) printf("%lld ", sum[i]); puts(""); */ } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...