QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#759562 | #9619. 乘积,欧拉函数,求和 | BaSEc1d | WA | 405ms | 5036kb | C++14 | 1.2kb | 2024-11-18 10:06:20 | 2024-11-18 10:06:21 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int>ttfa;
typedef long long ll;
const ll P=998244353;
inline ll fpr(ll b,ll t=P-2,ll x=1ll){
for(;t;t>>=1,b=b*b%P)
if(t&1)x=x*b%P;
return x;
}
const int N=3003,R=1<<16;
const ll pri[16]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53};
int n,id[N];
struct node{
ll val,res;int sta;
void calc(){
res=val;
for(int i=0,x=pri[i];i<16;++i,x=pri[i]){
while(res%x==0){
res/=x;
sta|=1<<id[x];
}
}
}
}a[N];
bool cmp(node x,node y){return x.res<y.res;}
ll dp[R],tmp[R],ans;
int main(){
for(int i=0;i<16;++i)id[pri[i]]=i;
scanf("%d",&n);
for(int i=1;i<=n;++i){
scanf("%d",&a[i]);
a[i].calc();
//printf("%d %lld\n",a[i].sta,a[i].res);
}
sort(a+1,a+1+n,cmp);
dp[0]=1ll;
for(int i=1;i<=n;++i){
memset(tmp,0,sizeof(tmp));
for(int s=R-1;s>=0;--s)
tmp[s|a[i].sta]=(tmp[s|a[i].sta]+dp[s]*a[i].val)%P;
ll k=a[i].res==1?1:(a[i].res-1)*fpr(a[i].res)%P;
for(int s=0;s<R;++s)
dp[s]=(dp[s]+tmp[s]*k%P)%P;
}
for(int i=0;i<16;++i){
ll x=(pri[i]-1)*fpr(pri[i])%P;
for(int s=0;s<R;++s)
if((s>>i)&1)dp[s]=dp[s]*x%P;
}
for(int s=0;s<R;++s)ans=(ans+dp[s])%P;
printf("%lld\n",ans);
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 3ms
memory: 4800kb
input:
5 1 6 8 6 2
output:
892
result:
ok single line: '892'
Test #2:
score: 0
Accepted
time: 0ms
memory: 4940kb
input:
5 3 8 3 7 8
output:
3157
result:
ok single line: '3157'
Test #3:
score: 0
Accepted
time: 403ms
memory: 5024kb
input:
2000 79 1 1 1 1 1 1 2803 1 1 1 1 1 1 1609 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2137 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 613 1 499 1 211 1 2927 1 1 1327 1 1 1123 1 907 1 2543 1 1 1 311 2683 1 1 1 1 2963 1 1 1 641 761 1 1 1 1 1 1 1 1 1 1 1 1489 2857 1 1 1 1 1 1 1 1 1 1 1 1 1 967 1 821 1 1 1 1 2143 1861...
output:
50965652
result:
ok single line: '50965652'
Test #4:
score: 0
Accepted
time: 405ms
memory: 5036kb
input:
2000 1 1 1 1 1 1 1 1 353 1 1 1 557 1 1 1 1 1 1 1 1 1 1 1 1423 1 1 1327 1 1 1 907 1 1 1 1 1 2971 1 1 1 2531 1 1 1 1 1 1 1 1 1 2099 1 1 1 1 1 1 1 1 1 1 1 1 1 1 199 2999 1 727 1 1 1 1 1 1 1 71 1 1 1 1 1 1 2503 1 176 1 1 1 1 1 1 1361 1013 1 1 1 1 1 1 1 2699 1 1 1 1 1 1 1 1 1 2897 1 1 1 1 1637 1 1 1367 1...
output:
420709530
result:
ok single line: '420709530'
Test #5:
score: 0
Accepted
time: 3ms
memory: 4932kb
input:
30 37 14 35 33 38 42 46 3 26 7 16 1 35 38 48 3 43 49 18 3 29 1 43 43 20 6 39 20 14 38
output:
262613273
result:
ok single line: '262613273'
Test #6:
score: 0
Accepted
time: 9ms
memory: 4936kb
input:
30 39 31 49 2 4 28 30 12 13 34 7 28 17 37 38 18 41 33 29 36 18 7 3 14 30 42 35 14 18 35
output:
234142118
result:
ok single line: '234142118'
Test #7:
score: -100
Wrong Answer
time: 45ms
memory: 4940kb
input:
200 53 37 234 248 66 30 64 181 38 130 250 27 199 226 43 185 207 241 38 296 68 18 145 20 64 127 57 30 168 267 221 116 115 192 17 26 5 63 3 127 52 48 229 58 69 111 20 244 234 35 48 217 179 189 89 60 285 106 43 104 36 28 62 281 104 38 281 264 140 275 105 20 203 271 222 262 123 10 82 263 118 254 229 222...
output:
119629509
result:
wrong answer 1st lines differ - expected: '617035263', found: '119629509'