QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#378666 | #8565. Basic Blooms | ucup-team3396# | WA | 100ms | 251068kb | C++14 | 1.3kb | 2024-04-06 14:06:25 | 2024-04-06 14:06:26 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
#define pdi pair<double,pair<pair<int,pair<int,int>>,int>>
#define mid ((l+r)>>1)
using namespace std;
const int mod=998244353;
double pw[17][1000005];
int mpw[17][1000005],k=0;
int pl[1000005];
int pre[1000005];
signed main(){
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
for(int i=2;i<=16;i++){
pw[i][0]=1;
mpw[i][0]=1;
for(int j=1;j<=1000000;j++) pw[i][j]=pw[i][j-1]*i,mpw[i][j]=mpw[i][j-1]*i%mod;
}
priority_queue<pdi,vector<pdi>,greater<pdi>> pq;
for(int i=2;i<=16;i++){
for(int j=1;j<i;j++){
pq.push(make_pair(pw[i][0]*j,make_pair(make_pair(i,make_pair(j,0)),mpw[i][0]*j%mod)));
}
}
while(k<=1000000){
auto f=pq.top(); pq.pop();
auto t=f;
// cout<<f.second.first.first<<" "<<f.second.first.second.first<<" "<<f.second.first.second.second<<" "<<t.second.second<<"\n";
t.second.first.second.second++;
t.first+=pw[t.second.first.first][t.second.first.second.second]*t.second.first.second.first;
(t.second.second+=mpw[t.second.first.first][t.second.first.second.second]*t.second.first.second.first)%=mod;
pq.push(t);
if(f.second.second!=pl[k]){
pl[++k]=f.second.second;
}
}
for(int i=1;i<=1000000;i++) (pl[i]+=pl[i-1])%=mod;
int t; cin>>t;
while(t--){
int l,r; cin>>l>>r;
cout<<(pl[r]+mod-pl[l-1])%mod<<"\n";
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 98ms
memory: 249436kb
input:
3 1 2 1 10 15 2000
output:
3 55 736374621
result:
ok 3 number(s): "3 55 736374621"
Test #2:
score: -100
Wrong Answer
time: 100ms
memory: 251068kb
input:
100000 26 99975 57 99944 28 99973 62 99939 71 99930 25 99976 53 99948 60 99941 73 99928 72 99929 30 99971 7 99994 3 99998 35 99966 73 99928 68 99933 83 99918 37 99964 63 99938 17 99984 34 99967 74 99927 6 99995 3 99998 23 99978 91 99910 39 99962 85 99916 82 99919 17 99984 61 99940 31 99970 44 99957 ...
output:
24320593 942766316 47352062 145159471 792187680 991856269 283424023 415555939 239316630 423607015 53109881 533196381 717987699 990823099 239316630 961094101 76651834 538538527 100093336 304082691 928372888 147171385 13118818 717987699 807604096 43410474 675028406 309992701 98278584 304082691 2352916...
result:
wrong answer 1st numbers differ - expected: '957904590', found: '24320593'