Created
February 10, 2013 00:04
-
-
Save msg555/4747669 to your computer and use it in GitHub Desktop.
Facebook Hacker Cup Round 2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <vector> | |
#include <cstring> | |
#include <cstdio> | |
#include <algorithm> | |
#include <map> | |
#include <set> | |
#include <queue> | |
#include <numeric> | |
#include <sys/types.h> | |
#include <sys/wait.h> | |
using namespace std; | |
int main() { | |
int T; scanf("%d", &T); | |
for(int t = 1; t <= T; t++) { | |
printf("Case #%d: ", t); | |
long long N, K, P; | |
scanf("%lld%lld%lld", &N, &K, &P); | |
if(N <= K) { | |
printf("1\n"); | |
continue; | |
} | |
if(P == 100) { | |
printf("x %lld\n", (N + K - 1) / K); | |
continue; | |
} | |
long long S = N - (N % K); | |
if(N % K == 0) S -= K; | |
long long R = S / K + 1; | |
for(; S > 0; ) { | |
long long n = 100 * S - P * N; | |
long long d = K * (100 - P); | |
if(n <= 0) { | |
if(n == 0) printf("Hello\n"); | |
break; | |
} | |
R = (n + d - 1) / d; | |
S = K * (R - 1); | |
} | |
printf("%lld\n", R); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment