QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#378663 | #8565. Basic Blooms | ucup-team3396# | ML | 0ms | 0kb | C++14 | 1.4kb | 2024-04-06 14:05:05 | 2024-04-06 14:05:09 |
answer
#include <bits/stdc++.h>
#define int long long
#define double long double
#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: 0
Memory Limit Exceeded
input:
3 1 2 1 10 15 2000
output:
3 55 736374621