QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#208857#4478. Jo loves counting11d10xyWA 383ms30876kbC++141.1kb2023-10-09 21:27:402023-10-09 21:27:41

Judging History

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

  • [2023-10-09 21:27:41]
  • 评测
  • 测评结果:WA
  • 用时:383ms
  • 内存:30876kb
  • [2023-10-09 21:27:40]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using lll=__int128;
constexpr ll mod=29ll<<57|1,i2=mod+1>>1,mxn=1e12;
constexpr int sqn=1000000;
auto ml=[](ll x,ll y)->ll{return(lll)x*y%mod;};
auto mns=[](ll x,ll y){return(x+mod-y)%mod;};
auto inv=[](ll p){ll res=1,t=mod-2;for(;t;t>>=1,p=ml(p,p))if(t&1)res=ml(res,p);return res;};
auto sum=[](ll n)->ll{return(lll)n*(n+1)/2;};
int p[sqn+10],pt;
basic_string<ll>h[79010],pp[79010];
ll n;
ll dfs(ll now,ll v,int i){
	if(i>pt||now>n/pp[i][2])return 0;
	ll res=dfs(now,v,i+1),nv,nn;
	for(int j=2;j<pp[i].size()&&now*pp[i][j]<=n;j++)
	nn=ml(now,pp[i][j]),nv=ml(v,h[i][j]),
	(res+=(dfs(nn,nv,i+1)+ml(nv,sum(n/nn)))%mod)%=mod;
	return res;
}
int main(){
	for(int i=2;i<=sqn;i++)
	if(!p[i])for(int j=p[++pt]=i;j<=sqn;j+=i)p[j]=1;
	for(int i=1;i<=pt;i++){
		pp[i]=h[i]={1};
		ll now=1;
		for(int j=1;pp[i][j-1]*p[i]<=mxn;j++)
		now=ml(now,p[i]),pp[i]+=pp[i][j-1]*p[i],
		h[i]+=(ml(pp[i][j],inv(j))+mod-now)%mod,(now+=h[i][j])%=mod;
	}
	int T;
	for(cin>>T;T--;)cin>>n,cout<<ml((sum(n)+dfs(1,1,1))%mod,inv(n))<<endl;
	return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 383ms
memory: 30876kb

input:

12
4
959139
9859
125987
209411
965585325539
213058376259
451941492387
690824608515
934002691939
1000000000000
1

output:

2
2544652967005436170
1531132428015608197
4112905740393076193
2210911161352244432
-929467365230714854
2488204735846976121
388277856510096152
-677089519945105509
-1382165388114069983
2816256849059238736
1

result:

wrong answer 6th lines differ - expected: '3734327250979959061', found: '-929467365230714854'