QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#187796#1085. Brave Seekers of UnicornsSublimeTextAC ✓91ms11516kbC++141.2kb2023-09-24 22:44:562023-09-24 22:44:56

Judging History

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

  • [2023-09-24 22:44:56]
  • 评测
  • 测评结果:AC
  • 用时:91ms
  • 内存:11516kb
  • [2023-09-24 22:44:56]
  • 提交

answer

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <climits>
#include <cstdlib>
#include <set>
#include <cmath>
#include <map>
#include <unordered_map>
#include <iomanip>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <unordered_set>
#include <assert.h>
#include <bitset>

using namespace std;
#define REP(i, l, r) for(int i = l; i <= r; ++i)
#define PER(i, r, l) for(int i = r; i >= l; --i)
namespace Main {
	const int N = 1e6 + 5;
	int n, mod;
	int f[N];
	void add(int &x, int y) {
		x += y;
		if (x < 0) x += mod;
		if(x >= mod) x -= mod;
	}
	int lg[N];
	int main() {
		ios::sync_with_stdio(false);
		cin.tie(0),cout.tie(0);
		cin >> n;
		mod = 998244353;
		lg[0] = -1;
		for(int i = 1; i <= n; ++i) {
			f[i] = 1;
			add(f[i], f[i - 1]);
			lg[i] = lg[i >> 1] + 1;
			for (int j = 0; (i >> j) > 1; ++j) {
				if((i >> j) & 1) {

					add(f[i], -f[(1 << (j + 1)) - 1]);
					add(f[i], f[(1 << j) - 1]);
				}
			}
			add(f[i], f[i - 1]);
		}
		cout << f[n] << '\n';
		return 0;
	}
}
int main() {
//	freopen("sort.in", "r", stdin);
//	freopen("sort.out", "w", stdout); 
	Main :: main();
	return 0;
} 
/*
5 
4 5 1 2 3
*/

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3648kb

input:

1

output:

1

result:

ok 1 number(s): "1"

Test #2:

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

input:

2

output:

3

result:

ok 1 number(s): "3"

Test #3:

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

input:

3

output:

6

result:

ok 1 number(s): "6"

Test #4:

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

input:

5

output:

26

result:

ok 1 number(s): "26"

Test #5:

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

input:

322

output:

782852421

result:

ok 1 number(s): "782852421"

Test #6:

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

input:

10

output:

728

result:

ok 1 number(s): "728"

Test #7:

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

input:

100

output:

234222727

result:

ok 1 number(s): "234222727"

Test #8:

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

input:

10000

output:

348787098

result:

ok 1 number(s): "348787098"

Test #9:

score: 0
Accepted
time: 87ms
memory: 11456kb

input:

1000000

output:

246427510

result:

ok 1 number(s): "246427510"

Test #10:

score: 0
Accepted
time: 87ms
memory: 11516kb

input:

999999

output:

525546416

result:

ok 1 number(s): "525546416"

Test #11:

score: 0
Accepted
time: 82ms
memory: 11068kb

input:

950000

output:

154241852

result:

ok 1 number(s): "154241852"

Test #12:

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

input:

999888

output:

254589934

result:

ok 1 number(s): "254589934"

Test #13:

score: 0
Accepted
time: 91ms
memory: 11380kb

input:

999423

output:

917909701

result:

ok 1 number(s): "917909701"

Test #14:

score: 0
Accepted
time: 51ms
memory: 11296kb

input:

600000

output:

546076071

result:

ok 1 number(s): "546076071"

Test #15:

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

input:

1337

output:

616951443

result:

ok 1 number(s): "616951443"