-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbullseye.cpp
52 lines (35 loc) · 956 Bytes
/
bullseye.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// link: http://code.google.com/codejam/contest/2418487/dashboard#s=p0&a=0
// name: Bullseye
#include<cstdio>
#include<vector>
#include<cmath>
#define MAX_R 1000000000
using namespace std;
bool canPaint(long long r, long long paint, long long circles){
return (2 * r + 2 * circles - 1) <= paint/circles;
}
int main(){
FILE * inFile, * outFile;
inFile = fopen ("A-large-practice.in","r");
outFile = fopen ("A-large-practice.out","w");
int T;
fscanf(inFile,"%d",&T);
for(int t=0;t<T;++t){
long long paint, r;
fscanf(inFile, "%lld%lld", &r, &paint);
long long result = 0;
long long low=1, high = paint;
while(low<high){
long long mid = (high+low)/2;
if(canPaint(r,paint,mid)){
low = mid+1;
result = mid;
}else{
high = mid;
}
}
fprintf(outFile,"Case #%d: %lld\n", (t+1),result);
}
fclose(inFile);
fclose(outFile);
}