QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#17425 | #1085. Brave Seekers of Unicorns | yahoco | AC ✓ | 75ms | 19312kb | C++11 | 929b | 2022-01-07 14:39:44 | 2022-05-04 14:55:14 |
Judging History
answer
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<map>
#include<stack>
#include<set>
#include<ctime>
#define iss ios::sync_with_stdio(false)
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int,int>pii;
const int MAXN=1e6+5;
const int mod=998244353;
const int inf=0x3f3f3f3f;
ll sum[MAXN],dp[MAXN];
int main()
{
int n;
cin>>n;
for(int i=1;i<=n;i++)
{
dp[i]=sum[i-1]+1;
int temp=i;
int x=1;
while(temp)
{
if((temp&1)&&temp!=1)
{
dp[i]=(mod+dp[i]-sum[min(x*2-1,i)]+sum[min(x-1,i)])%mod;
//cout<<min(x,i-1)<<" "<<min(x*2-1,i-1)<<endl;
}
temp>>=1;
x=x*2;
}
sum[i]=(sum[i-1]+dp[i])%mod;
}
printf("%lld\n",sum[n]);
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 5764kb
input:
1
output:
1
result:
ok 1 number(s): "1"
Test #2:
score: 0
Accepted
time: 3ms
memory: 5700kb
input:
2
output:
3
result:
ok 1 number(s): "3"
Test #3:
score: 0
Accepted
time: 0ms
memory: 5736kb
input:
3
output:
6
result:
ok 1 number(s): "6"
Test #4:
score: 0
Accepted
time: 2ms
memory: 5708kb
input:
5
output:
26
result:
ok 1 number(s): "26"
Test #5:
score: 0
Accepted
time: 4ms
memory: 5744kb
input:
322
output:
782852421
result:
ok 1 number(s): "782852421"
Test #6:
score: 0
Accepted
time: 0ms
memory: 5700kb
input:
10
output:
728
result:
ok 1 number(s): "728"
Test #7:
score: 0
Accepted
time: 2ms
memory: 5624kb
input:
100
output:
234222727
result:
ok 1 number(s): "234222727"
Test #8:
score: 0
Accepted
time: 2ms
memory: 5828kb
input:
10000
output:
348787098
result:
ok 1 number(s): "348787098"
Test #9:
score: 0
Accepted
time: 62ms
memory: 19280kb
input:
1000000
output:
246427510
result:
ok 1 number(s): "246427510"
Test #10:
score: 0
Accepted
time: 73ms
memory: 19312kb
input:
999999
output:
525546416
result:
ok 1 number(s): "525546416"
Test #11:
score: 0
Accepted
time: 67ms
memory: 19012kb
input:
950000
output:
154241852
result:
ok 1 number(s): "154241852"
Test #12:
score: 0
Accepted
time: 75ms
memory: 19244kb
input:
999888
output:
254589934
result:
ok 1 number(s): "254589934"
Test #13:
score: 0
Accepted
time: 66ms
memory: 19276kb
input:
999423
output:
917909701
result:
ok 1 number(s): "917909701"
Test #14:
score: 0
Accepted
time: 37ms
memory: 13952kb
input:
600000
output:
546076071
result:
ok 1 number(s): "546076071"
Test #15:
score: 0
Accepted
time: 3ms
memory: 5764kb
input:
1337
output:
616951443
result:
ok 1 number(s): "616951443"