QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#187790 | #1085. Brave Seekers of Unicorns | yjf1225 | AC ✓ | 77ms | 11700kb | C++14 | 1.2kb | 2023-09-24 22:34:53 | 2023-09-24 22:34:53 |
Judging History
answer
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
using namespace std;
namespace yjf{
const int N=1000010;
const int Mod=998244353;
int f[N];
int sum[N];
int main(){
//int t=-1;
//int t2=1;
//cout<<(t2<<t)<<endl;
int n;
scanf("%d",&n);
f[0]=1;
sum[0]=1;
for(int i=1;i<=n;i++){
f[i]+=sum[i-1];
f[i]%=Mod;
/*
for(int j=0;j<i;j++){
if((i^j)<j){
f[i]-=f[i^j];
f[i]=(f[i]%Mod+Mod)%Mod;
}
}
*/
int j;
for(j=20;j>=0;j--){
if((i>>j)&1){
j--;
break;
}
}
for(;j>=0;j--){
if((i>>j)&1){
//cout<<"!!!"<<tmp<<" "<<(j-1)<<" "<<((tmp+1)<<j)<<" "<<(1<<(j-1))<<" "<<((tmp+1)<<j)-1<<endl;
//if((1<<j)-1>=0){
f[i]-=((sum[(1<<j)+(1<<j)-1]-sum[(1<<j)-1])%Mod+Mod)%Mod;
//}
//else{
// f[i]-=((sum[(1<<j)+(1<<j)-1])%Mod+Mod)%Mod;
//}
f[i]=(f[i]%Mod+Mod)%Mod;
}
}
sum[i]=(sum[i-1]+f[i])%Mod;
//cout<<f[i]<<endl;
}
printf("%d\n",((sum[n]-sum[0])%Mod+Mod)%Mod);
return 0;
}
}
int main(){
//freopen("xor.in","r",stdin);
//freopen("xor.out","w",stdout);
return yjf::main();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 5936kb
input:
1
output:
1
result:
ok 1 number(s): "1"
Test #2:
score: 0
Accepted
time: 1ms
memory: 5916kb
input:
2
output:
3
result:
ok 1 number(s): "3"
Test #3:
score: 0
Accepted
time: 1ms
memory: 5996kb
input:
3
output:
6
result:
ok 1 number(s): "6"
Test #4:
score: 0
Accepted
time: 1ms
memory: 5932kb
input:
5
output:
26
result:
ok 1 number(s): "26"
Test #5:
score: 0
Accepted
time: 0ms
memory: 5852kb
input:
322
output:
782852421
result:
ok 1 number(s): "782852421"
Test #6:
score: 0
Accepted
time: 1ms
memory: 5916kb
input:
10
output:
728
result:
ok 1 number(s): "728"
Test #7:
score: 0
Accepted
time: 0ms
memory: 5816kb
input:
100
output:
234222727
result:
ok 1 number(s): "234222727"
Test #8:
score: 0
Accepted
time: 0ms
memory: 5904kb
input:
10000
output:
348787098
result:
ok 1 number(s): "348787098"
Test #9:
score: 0
Accepted
time: 77ms
memory: 11700kb
input:
1000000
output:
246427510
result:
ok 1 number(s): "246427510"
Test #10:
score: 0
Accepted
time: 75ms
memory: 11688kb
input:
999999
output:
525546416
result:
ok 1 number(s): "525546416"
Test #11:
score: 0
Accepted
time: 74ms
memory: 11500kb
input:
950000
output:
154241852
result:
ok 1 number(s): "154241852"
Test #12:
score: 0
Accepted
time: 74ms
memory: 11644kb
input:
999888
output:
254589934
result:
ok 1 number(s): "254589934"
Test #13:
score: 0
Accepted
time: 77ms
memory: 11692kb
input:
999423
output:
917909701
result:
ok 1 number(s): "917909701"
Test #14:
score: 0
Accepted
time: 45ms
memory: 10012kb
input:
600000
output:
546076071
result:
ok 1 number(s): "546076071"
Test #15:
score: 0
Accepted
time: 1ms
memory: 5812kb
input:
1337
output:
616951443
result:
ok 1 number(s): "616951443"