QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#233481 | #5359. 面国建设 | xyz123 | 49 | 495ms | 54420kb | C++14 | 2.5kb | 2023-10-31 18:12:05 | 2023-10-31 18:12:05 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
long long T,a,b,c,d[1000001],v[1000001],o,h[1000001],fa[1000001],q,w,e,an,cn,fac[1000001],inv[1000001],st[1000001],u[1000001],g[1000001];
char s[1000001];
struct p{long long q,w;}l[1000001];
long long pow_(long long qq,long long ww){long long ee=1;while(ww){if(ww&1) ee*=qq,ee%=mod;qq*=qq,qq%=mod,ww>>=1;}return ee%mod;}
inline int read(){int x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9'){x=(x<<3)+(x<<1)+c-'0';c=getchar();}return x*f;}
void add(long long qq,long long ww){l[++o].q=ww,l[o].w=h[qq],h[qq]=o;}
long long gcd(long long qq,long long ww){return !ww?qq:gcd(ww,qq%ww);}
long long find(long long qq){return qq==fa[qq]?qq:fa[qq]=find(fa[qq]);}
void merge(long long qq,long long ww){long long f1=find(qq),f2=find(ww);if(f1==f2) return;fa[f1]=f2;}
long long C(long long qq,long long ww){return fac[qq]*inv[ww]%mod*inv[qq-ww]%mod;}
vector<long long> qu[1000001];
int main()
{
// freopen("1.in","r",stdin);
srand((unsigned)(time(0)^(*new int)));
fac[0]=1;for(int i=1;i<=1000000;i++) fac[i]=fac[i-1]*i%mod;
inv[1000000]=pow_(fac[1000000],mod-2);for(int i=999999;i>=0;i--) inv[i]=inv[i+1]*(i+1)%mod;
d[1]=2;g[1]=2;
for(int i=2;i<=6000;i++)
{
d[i]=g[i]=1e9;
for(int j=1;j<=i/2;j++)
{
g[i]=min(g[i],g[j]+g[i-j]);
}
for(int j=1;j<=i/2;j++)
{
for(int k=0;k<qu[j].size();k++)
{
for(int m=0;m<qu[i-j].size();m++)
{
v[qu[j][k]+qu[i-j][m]]=1;
}
}
}
for(int j=1;j<i;j++)
{
for(int k=0;k<qu[i-j].size();k++)
{
for(int m=g[j];m<=j*2&&m+qu[i-j][k]<g[i];m++)
{
v[m+qu[i-j][k]]=1;
}
}
}
for(int j=sqrt(i);j>=1;j--)
{
if(i%j==0)
{
if(j+i/j<g[i]) v[j+i/j]=1;
}
}
while(v[g[i]-1])
{
--g[i];v[g[i]]=0;
}
for(int j=1;j<g[i];j++) if(v[j]) qu[i].push_back(j);
for(int j=0;j<qu[i].size();j++) v[qu[i][j]]=0;
for(int j=1;j<=i/2;j++)
{
for(int k=0;k<qu[j].size();k++)
{
for(int m=0;m<qu[i-j].size();m++)
{
v[qu[j][k]+qu[i-j][m]]=0;
}
}
}
for(int j=1;j<i;j++)
{
for(int k=0;k<qu[i-j].size();k++)
{
for(int m=g[j];m<=j*2&&m+qu[i-j][k]<=g[i];m++)
{
v[m+qu[i-j][k]]=0;
}
}
}
}
scanf("%lld%lld",&a,&b);b/=2;
for(int i=1;i<=a;i++)
{
long long gg=min((long long)(i*2),b);
if(gg>=g[i]) an+=gg-g[i]+1;
for(int j=0;j<qu[i].size();j++)
{
if(qu[i][j]<=gg&&qu[i][j]<g[i]) ++an;
}
}
printf("%lld",an);
return 0;
}
詳細信息
Subtask #1:
score: 6
Accepted
Test #1:
score: 6
Accepted
time: 491ms
memory: 54040kb
input:
4 10
output:
7
result:
ok single line: '7'
Test #2:
score: 0
Accepted
time: 490ms
memory: 51156kb
input:
7 2
output:
0
result:
ok single line: '0'
Test #3:
score: 0
Accepted
time: 486ms
memory: 50876kb
input:
6 6
output:
2
result:
ok single line: '2'
Test #4:
score: 0
Accepted
time: 495ms
memory: 53988kb
input:
10 7
output:
2
result:
ok single line: '2'
Test #5:
score: 0
Accepted
time: 484ms
memory: 53908kb
input:
8 10
output:
8
result:
ok single line: '8'
Test #6:
score: 0
Accepted
time: 493ms
memory: 53720kb
input:
10 8
output:
5
result:
ok single line: '5'
Subtask #2:
score: 12
Accepted
Dependency #1:
100%
Accepted
Test #7:
score: 12
Accepted
time: 493ms
memory: 53772kb
input:
399 994
output:
125266
result:
ok single line: '125266'
Test #8:
score: 0
Accepted
time: 491ms
memory: 53780kb
input:
742 645
output:
184225
result:
ok single line: '184225'
Test #9:
score: 0
Accepted
time: 483ms
memory: 54420kb
input:
932 900
output:
328424
result:
ok single line: '328424'
Test #10:
score: 0
Accepted
time: 491ms
memory: 53840kb
input:
943 971
output:
357500
result:
ok single line: '357500'
Test #11:
score: 0
Accepted
time: 494ms
memory: 50992kb
input:
955 897
output:
335817
result:
ok single line: '335817'
Test #12:
score: 0
Accepted
time: 482ms
memory: 52124kb
input:
903 971
output:
340678
result:
ok single line: '340678'
Test #13:
score: 0
Accepted
time: 482ms
memory: 53332kb
input:
954 978
output:
364964
result:
ok single line: '364964'
Test #14:
score: 0
Accepted
time: 490ms
memory: 53540kb
input:
908 902
output:
319849
result:
ok single line: '319849'
Test #15:
score: 0
Accepted
time: 486ms
memory: 53180kb
input:
934 908
output:
332030
result:
ok single line: '332030'
Test #16:
score: 0
Accepted
time: 495ms
memory: 50396kb
input:
961 924
output:
348391
result:
ok single line: '348391'
Subtask #3:
score: 31
Accepted
Dependency #1:
100%
Accepted
Dependency #2:
100%
Accepted
Test #17:
score: 31
Accepted
time: 492ms
memory: 52348kb
input:
1951 2977
output:
2228950
result:
ok single line: '2228950'
Test #18:
score: 0
Accepted
time: 491ms
memory: 50560kb
input:
4626 5415
output:
10254469
result:
ok single line: '10254469'
Test #19:
score: 0
Accepted
time: 482ms
memory: 51064kb
input:
5983 4766
output:
12197679
result:
ok single line: '12197679'
Test #20:
score: 0
Accepted
time: 482ms
memory: 50456kb
input:
5094 5425
output:
11472637
result:
ok single line: '11472637'
Test #21:
score: 0
Accepted
time: 490ms
memory: 50632kb
input:
5598 4989
output:
11826716
result:
ok single line: '11826716'
Test #22:
score: 0
Accepted
time: 482ms
memory: 50516kb
input:
5577 5188
output:
12208146
result:
ok single line: '12208146'
Test #23:
score: 0
Accepted
time: 484ms
memory: 50580kb
input:
5688 5804
output:
13807758
result:
ok single line: '13807758'
Test #24:
score: 0
Accepted
time: 492ms
memory: 54108kb
input:
5856 5309
output:
13161066
result:
ok single line: '13161066'
Test #25:
score: 0
Accepted
time: 488ms
memory: 50624kb
input:
5378 5859
output:
13061554
result:
ok single line: '13061554'
Test #26:
score: 0
Accepted
time: 490ms
memory: 53800kb
input:
5729 5635
output:
13554877
result:
ok single line: '13554877'
Subtask #4:
score: 0
Wrong Answer
Dependency #1:
100%
Accepted
Dependency #2:
100%
Accepted
Dependency #3:
100%
Accepted
Test #27:
score: 0
Wrong Answer
time: 491ms
memory: 53796kb
input:
177004 361104
output:
23808287277
result:
wrong answer 1st lines differ - expected: '23708315017', found: '23808287277'