QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#786988#1085. Brave Seekers of Unicornscyj888AC ✓55ms11636kbC++14968b2024-11-27 07:40:562024-11-27 07:40:56

Judging History

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

  • [2024-11-27 07:40:56]
  • 评测
  • 测评结果:AC
  • 用时:55ms
  • 内存:11636kb
  • [2024-11-27 07:40:56]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define ott(i, l, r) for (int i = (l); i <= (r); i ++)
#define tto(i, l, r) for (int i = (r); i >= (l); i --)
#define fi first
#define se second 
#define pb push_back
#define all(x) x.begin (), x.end ()
typedef double db;
typedef long long ll;
typedef long double ld;
int read () {
	int x = 0; bool f = false; char c = getchar ();
	while (!isdigit (c)) f |= (c == '-'), c = getchar ();
	while (isdigit (c)) x = (x << 3) + (x << 1) + (c ^ 48), c = getchar ();
	return f ? -x : x;
}
const int N = 1e6 + 110;
int n, mod;
int f[N], s[N];
int main () {
	n = read (), mod = 998244353;
	s[1] = f[1] = 1;
	ott (i, 2, n) {
		f[i] = (s[i - 1] + 1) % mod;
		int j = 20; while (!(i >> j & 1)) -- j;
		tto (k, 0, j - 1) if (i >> k & 1) (f[i] += (s[(1 << k) - 1] + mod - s[(1 << k + 1) - 1]) % mod) %= mod;
		s[i] = (s[i - 1] + f[i]) % mod;
	}
	printf ("%d\n", s[n]);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 5820kb

input:

1

output:

1

result:

ok 1 number(s): "1"

Test #2:

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

input:

2

output:

3

result:

ok 1 number(s): "3"

Test #3:

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

input:

3

output:

6

result:

ok 1 number(s): "6"

Test #4:

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

input:

5

output:

26

result:

ok 1 number(s): "26"

Test #5:

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

input:

322

output:

782852421

result:

ok 1 number(s): "782852421"

Test #6:

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

input:

10

output:

728

result:

ok 1 number(s): "728"

Test #7:

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

input:

100

output:

234222727

result:

ok 1 number(s): "234222727"

Test #8:

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

input:

10000

output:

348787098

result:

ok 1 number(s): "348787098"

Test #9:

score: 0
Accepted
time: 54ms
memory: 11636kb

input:

1000000

output:

246427510

result:

ok 1 number(s): "246427510"

Test #10:

score: 0
Accepted
time: 55ms
memory: 11620kb

input:

999999

output:

525546416

result:

ok 1 number(s): "525546416"

Test #11:

score: 0
Accepted
time: 52ms
memory: 11432kb

input:

950000

output:

154241852

result:

ok 1 number(s): "154241852"

Test #12:

score: 0
Accepted
time: 55ms
memory: 11552kb

input:

999888

output:

254589934

result:

ok 1 number(s): "254589934"

Test #13:

score: 0
Accepted
time: 55ms
memory: 11616kb

input:

999423

output:

917909701

result:

ok 1 number(s): "917909701"

Test #14:

score: 0
Accepted
time: 30ms
memory: 10008kb

input:

600000

output:

546076071

result:

ok 1 number(s): "546076071"

Test #15:

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

input:

1337

output:

616951443

result:

ok 1 number(s): "616951443"