QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#115350 | #5957. Allergy Testing | zhouhuanyi | 0 | 9059ms | 9656kb | C++11 | 1.6kb | 2023-06-25 22:13:28 | 2023-06-25 22:13:30 |
Judging History
answer
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#define N 400000
#define inf 1e18
using namespace std;
long long read()
{
char c=0;
long long sum=0;
while (c<'0'||c>'9') c=getchar();
while ('0'<=c&&c<='9') sum=sum*10+c-'0',c=getchar();
return sum;
}
int T,length;
long long n,A,B,st[N+1],dp[N+1];
long long F(long long x)
{
int ps=lower_bound(st+1,st+length+1,x+1)-st-1;
long long maxn=0,c1,c2;
if (ps) maxn=max(maxn,dp[ps]);
maxn=max(maxn,x/A+1);
if (x>=B)
{
c1=(x-B)/A,c2=x/A;
maxn=max(maxn,(long long)(min((__int128)(c1+1)*(c1+2)/2+c2-c1,(__int128)(n+1))));
}
return min(maxn,n+1);
}
int main()
{
long long res;
T=read();
for (int qt=1;qt<=T;++qt)
{
n=read(),A=read(),B=read(),length=0,res=-1;
for (int i=2;i<=49;++i)
{
if (i==2)
{
for (int j=0;j<=200000;++j) st[++length]=j*A+i*B;
}
else if (i==3)
{
for (int j=0;j<=20000;++j) st[++length]=j*A+i*B;
}
else if (i==4)
{
for (int j=0;j<=2000;++j) st[++length]=j*A+i*B;
}
else
{
for (int j=0;j<=400;++j) st[++length]=j*A+i*B;
}
}
sort(st+1,st+length+1),length=unique(st+1,st+length+1)-st-1;
for (int i=1;i<=length;++i)
{
dp[i]=0;
if (st[i]>=A) dp[i]=max(dp[i],min(F(st[i]-A)+1,n+1));
if (st[i]>=B) dp[i]=max(dp[i],min(F(st[i]-A)+F(st[i]-B),n+1));
}
for (int i=log(inf)/log(2);i>=0;--i)
if (res+(1ll<<i)<=inf&&F(res+(1ll<<i))<n)
res+=(1ll<<i);
res++,printf("Case #%d: %lld\n",qt,res);
}
return 0;
}
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 9059ms
memory: 9216kb
input:
200 248794459979751 2 23 647141011809434 1 1 1 7 72 440039160553207 2 15 518185192633838 50 99 723438516824256 1 19 367397848971042 72 74 161202117156326 40 40 14195704645139 1 1 344123426089538 17 70 597633495749779 3 74 1 31 89 899376930571631 3 52 776312678496459 1 1 657958323101218 1 91 73670160...
output:
Case #1: 396 Case #2: 50 Case #3: 0 Case #4: 306 Case #5: 3530 Case #6: 286 Case #7: 3574 Case #8: 1920 Case #9: 44 Case #10: 1785 Case #11: 1023 Case #12: 0 Case #13: 812 Case #14: 50 Case #15: 883 Case #16: 2958 Case #17: 245 Case #18: 870 Case #19: 917 Case #20: 88 Case #21: 49 Case #22: 4200 Cas...
result:
wrong answer 1st lines differ - expected: 'Case #1: 395', found: 'Case #1: 396'
Subtask #2:
score: 0
Wrong Answer
Test #2:
score: 0
Wrong Answer
time: 8535ms
memory: 9656kb
input:
200 746993929581932 142696274786 428088824356 821296104130392 9404 314602795522 732393029543810 1 491862101132 334980960239832 476164015712 689458402567 34360471927936 219762102255 749514425501 43149753727929 2637 277305648790 1 306403840371 881644374633 6764562905980 1 1 515691552138897 74612952475...
output:
Case #1: 12842664730702 Case #2: 630293201260 Case #3: 491900360801 Case #4: 28024513280698 Case #5: 19283686047214 Case #6: 301802693346 Case #7: 0 Case #8: 43 Case #9: 41808463777671 Case #10: 12759827966790 Case #11: 44 Case #12: 681182597827 Case #13: 12933280433300 Case #14: 8375286538639 Case ...
result:
wrong answer 1st lines differ - expected: 'Case #1: 12699968455924', found: 'Case #1: 12842664730702'