QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#273228#7881. Computational Complexityucup-team266#WA 360ms137736kbC++142.4kb2023-12-02 22:12:372023-12-02 22:12:38

Judging History

你现在查看的是最新测评结果

  • [2023-12-02 22:12:38]
  • 评测
  • 测评结果:WA
  • 用时:360ms
  • 内存:137736kb
  • [2023-12-02 22:12:37]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll G=1e17;
ll mod;
int id[70][70][70][70],cn,ai[100010],bi[100010],ci[100010],di[100010];
ll f[100100],g[100100],va[100100];
const int p[4]={2,3,5,7};
int fz[4];
void dfs(int x,ll z){
	if(x==4){
		id[fz[0]][fz[1]][fz[2]][fz[3]]=++cn;
		ai[cn]=fz[0],bi[cn]=fz[1],ci[cn]=fz[2],di[cn]=fz[3];
		va[cn]=z;return;
	}
	for(int i=0;;i++){
		if(z>G)break;
		fz[x]=i,dfs(x+1,z),z*=p[x]; 
	}
}
void aa(ll &x,ll y){x+=y,x-=((x>=mod)?mod:0);}
void ad(ll &x,ll y){x+=y;}
ll O;
ll fp[10],gp[10];
struct jr{ll x,z;}fm[10100000];int n;
ll nt[100100],a1[101000],a2[101000];int is[101000];
void sol(){
	n=0;
	for(int u=1;u<=cn;u++){
		int a=ai[u],b=bi[u],c=ci[u],d=di[u];
		for(int i=0;i<4;i++){
			int V=id[a+(i==0)][b+(i==1)][c+(i==2)][d+(i==3)];
			if(!V)continue;
			ad(g[V],f[u]);
			for(int t=0;t<=5;t++){
				ll l=max(va[u]*6,va[V]*t),r=va[V]*(t+1);
				ll Z=((__int128)f[u])*gp[t]%mod;
				if(l<r)fm[++n]=(jr){l,Z},fm[++n]=(jr){r,-Z};
			}
		}
		for(int i=0;i<4;i++){
			int V;
			if(i==3)V=id[a+2][b][c][d];
			else V=id[a+(i==0)][b+(i==1)][c+(i==2)][d];
			ad(f[V],g[u]);
			for(int t=0;t<=5;t++){
				ll l=max(va[u]*6,va[V]*t),r=va[V]*(t+1);
				ll Z=((__int128)g[u])*fp[t]%mod;
				if(l<r)fm[++n]=(jr){l,Z},fm[++n]=(jr){r,-Z};
			}
		}
	}
}
int main(){
	dfs(0,1);
	int T;ll t1,t2;
	scanf("%lld%lld%d%lld",&t1,&t2,&T,&mod);
	for(int i=1;i<=T;i++)scanf("%lld",&nt[i]),is[i]=i;
	sort(is+1,is+T+1,[&](int x,int y){return nt[x]<nt[y];});
	fp[0]=t1,gp[0]=t2;
	for(int i=1;i<=5;i++){
		ad(fp[i],gp[i/2]),ad(fp[i],gp[i/3]),ad(fp[i],gp[i/5]),ad(fp[i],gp[i/7]);
		fp[i]=max(fp[i],1ll*i);
		ad(gp[i],fp[i/2]),ad(gp[i],fp[i/3]),ad(gp[i],fp[i/5]),ad(gp[i],fp[i/4]);
		gp[i]=max(gp[i],1ll*i);
	}
	for(int i=1;i<=5;i++)fp[i]%=mod,gp[i]%=mod;
	memset(f,0,sizeof(f)),memset(g,0,sizeof(g));
	f[1]=1,sol();
	sort(fm+1,fm+n+1,[&](jr a,jr b){return a.x<b.x;});
	ll s=0;int k=1;
	for(int i=1;i<=T;i++){
		while(k<=n&&fm[k].x<=nt[is[i]])(s+=fm[k].z)%=mod,k++;
		a1[is[i]]=s;
	}
	memset(f,0,sizeof(f)),memset(g,0,sizeof(g));
	g[1]=1,sol();
	sort(fm+1,fm+n+1,[&](jr a,jr b){return a.x<b.x;});
	s=0;k=1;
	for(int i=1;i<=T;i++){
		while(k<=n&&fm[k].x<=nt[is[i]])(s+=fm[k].z)%=mod,k++;
		a2[is[i]]=s;
	}
	for(int i=1;i<=T;i++){
		if(nt[i]<=5)printf("%lld %lld\n",fp[nt[i]],gp[nt[i]]); 
		else printf("%lld %lld\n",(a1[i]+mod)%mod,(a2[i]+mod)%mod);
	}
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 348ms
memory: 137600kb

input:

1958 920 10 100000000000
0
1
2
3
10
100
200
1000
19580920
20232023

output:

1958 920
3680 7832
10592 9554
17504 11276
50294 64826
784112 893714
1894550 1905470
12057866 12979424
71481494756 48626708512
28127864908 7251681354

result:

ok 20 numbers

Test #2:

score: 0
Accepted
time: 360ms
memory: 137428kb

input:

0 0 10 100000000000
0
1
2
3
4
10
20
30
40
100

output:

0 0
1 1
2 2
3 3
4 4
11 12
25 26
41 41
55 58
162 172

result:

ok 20 numbers

Test #3:

score: -100
Wrong Answer
time: 353ms
memory: 137736kb

input:

2023 2023 10 2023
0
1
2
3
4
5
6
7
8
9

output:

2023 2023
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0

result:

wrong answer 1st numbers differ - expected: '0', found: '2023'