QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#94498 | #5833. Number Game | eyiigjkn | 41 ✓ | 2060ms | 3796kb | C++14 | 975b | 2023-04-06 14:19:35 | 2023-04-06 14:19:36 |
Judging History
answer
# include <bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr int N=31;
int fib[40];
ll slv(int A,int B)
{
if(!A || !B) return 0;
ll ans=0;
for(int i=0;i+2<=N;i+=2)
{
for(int a=1,b=0;a<=A && fib[i]*a<=A && fib[i+1]*a<=B;a++)
{
while(fib[i]*a+fib[i+1]*(b+1)<=A && fib[i+1]*a+fib[i+2]*(b+1)<=B) b++;
while(fib[i]*a+fib[i+1]*b>A || fib[i+1]*a+fib[i+2]*b>B) b--;
ans+=max(b-2*a+1,0);
}
for(int a=0,b=1;b<=B && fib[i]*b<=B && fib[i+1]*b<=A;b++)
{
while(fib[i+2]*(a+1)+fib[i+1]*b<=A && fib[i+1]*(a+1)+fib[i]*b<=B) a++;
while(fib[i+2]*a+fib[i+1]*b>A || fib[i+1]*a+fib[i]*b>B) a--;
ans+=max(a-2*b+1,0);
}
}
return ans;
}
int main()
{
int T,L1,L2,R1,R2;
fib[0]=1;fib[1]=0;
for(int i=2;i<=N;i++) fib[i]=fib[i-1]+fib[i-2];
cin>>T;
for(int _=1;_<=T;_++)
{
scanf("%d%d%d%d",&L1,&R1,&L2,&R2);
printf("Case #%d: %lld\n",_,slv(R1,R2)-slv(L1-1,R2)-slv(R1,L2-1)+slv(L1-1,L2-1));
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 16
Accepted
Test #1:
score: 16
Accepted
time: 1372ms
memory: 3796kb
input:
100 5 5 8 8 11 11 2 2 1 6 1 6 1 5 9 20 1 1 1 1 1000000 1000000 1000000 1000000 1000000 1000000 1 1 1 31 1 31 39 39 24 24 37 67 7 17 1 24 40 63 1 30 43 69 34 55 46 76 44 54 39 53 47 77 24 40 48 50 24 49 45 61 7 37 27 56 37 67 31 49 20 48 8 37 42 60 20 50 30 31 1 31 37 50 40 61 17 44 34 42 1 29 22 36 ...
output:
Case #1: 0 Case #2: 1 Case #3: 20 Case #4: 60 Case #5: 0 Case #6: 0 Case #7: 1 Case #8: 582 Case #9: 1 Case #10: 341 Case #11: 576 Case #12: 796 Case #13: 153 Case #14: 0 Case #15: 415 Case #16: 20 Case #17: 446 Case #18: 187 Case #19: 100 Case #20: 456 Case #21: 2 Case #22: 369 Case #23: 323 Case #...
result:
ok 100 lines
Subtask #2:
score: 25
Accepted
Test #2:
score: 25
Accepted
time: 2060ms
memory: 3620kb
input:
100 5 5 8 8 11 11 2 2 1 6 1 6 1 5 9 20 1 1 1 1 1000000 1000000 1000000 1000000 1000000 1000000 1 1 1 1000000 1 1000000 88555 88555 54730 54730 94333 94333 58301 58301 1233 74802 1526 99178 1403 98398 100 99952 2314 98444 13714 78345 6209 77129 27966 59955 323 35101 11059 46724 6347 98575 43370 99140...
output:
Case #1: 0 Case #2: 1 Case #3: 20 Case #4: 60 Case #5: 0 Case #6: 0 Case #7: 1 Case #8: 618033606782 Case #9: 0 Case #10: 1 Case #11: 4535447945 Case #12: 5930368367 Case #13: 3486019386 Case #14: 984600957 Case #15: 716856938 Case #16: 2351372232 Case #17: 4746234753 Case #18: 1948555868 Case #19: ...
result:
ok 100 lines
Extra Test:
score: 0
Extra Test Passed