QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#32751#1085. Brave Seekers of UnicornsWu_RenAC ✓70ms7648kbC++17382b2022-05-23 15:32:402022-05-23 15:32:42

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-05-23 15:32:42]
  • 评测
  • 测评结果:AC
  • 用时:70ms
  • 内存:7648kb
  • [2022-05-23 15:32:40]
  • 提交

answer

#include <bits/stdc++.h>
const int mod=998244353;
using namespace std;
int n,f[1000010];
void qmo(int &x){
	x+=(x>>31)&mod;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		qmo(f[i]=f[i-1]+1-mod);
		for(int j=0;(i>>j)>1;j++) if((i>>j)&1){
			qmo(f[i]-=f[(1<<(j+1))-1]);
			qmo(f[i]+=f[(1<<j)-1]-mod);
		}
		qmo(f[i]+=f[i-1]-mod);
	}
	printf("%d\n",f[n]);
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 3ms
memory: 3668kb

input:

1

output:

1

result:

ok 1 number(s): "1"

Test #2:

score: 0
Accepted
time: 3ms
memory: 3728kb

input:

2

output:

3

result:

ok 1 number(s): "3"

Test #3:

score: 0
Accepted
time: 3ms
memory: 3740kb

input:

3

output:

6

result:

ok 1 number(s): "6"

Test #4:

score: 0
Accepted
time: 1ms
memory: 3736kb

input:

5

output:

26

result:

ok 1 number(s): "26"

Test #5:

score: 0
Accepted
time: 3ms
memory: 3788kb

input:

322

output:

782852421

result:

ok 1 number(s): "782852421"

Test #6:

score: 0
Accepted
time: 2ms
memory: 3656kb

input:

10

output:

728

result:

ok 1 number(s): "728"

Test #7:

score: 0
Accepted
time: 2ms
memory: 3616kb

input:

100

output:

234222727

result:

ok 1 number(s): "234222727"

Test #8:

score: 0
Accepted
time: 1ms
memory: 3788kb

input:

10000

output:

348787098

result:

ok 1 number(s): "348787098"

Test #9:

score: 0
Accepted
time: 59ms
memory: 7632kb

input:

1000000

output:

246427510

result:

ok 1 number(s): "246427510"

Test #10:

score: 0
Accepted
time: 63ms
memory: 7648kb

input:

999999

output:

525546416

result:

ok 1 number(s): "525546416"

Test #11:

score: 0
Accepted
time: 67ms
memory: 7432kb

input:

950000

output:

154241852

result:

ok 1 number(s): "154241852"

Test #12:

score: 0
Accepted
time: 62ms
memory: 7572kb

input:

999888

output:

254589934

result:

ok 1 number(s): "254589934"

Test #13:

score: 0
Accepted
time: 70ms
memory: 7636kb

input:

999423

output:

917909701

result:

ok 1 number(s): "917909701"

Test #14:

score: 0
Accepted
time: 44ms
memory: 6104kb

input:

600000

output:

546076071

result:

ok 1 number(s): "546076071"

Test #15:

score: 0
Accepted
time: 0ms
memory: 3732kb

input:

1337

output:

616951443

result:

ok 1 number(s): "616951443"