Skip to content

Instantly share code, notes, and snippets.

@msg555
Created February 10, 2013 00:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save msg555/4747669 to your computer and use it in GitHub Desktop.
Save msg555/4747669 to your computer and use it in GitHub Desktop.
Facebook Hacker Cup Round 2
#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