QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#187795#1085. Brave Seekers of UnicornsSublimeTextWA 1ms3612kbC++141.2kb2023-09-24 22:43:552023-09-24 22:43:56

Judging History

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

  • [2023-09-24 22:43:56]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3612kb
  • [2023-09-24 22:43:55]
  • 提交

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;
		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: 1ms
memory: 3600kb

input:

1

output:

1

result:

ok 1 number(s): "1"

Test #2:

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

input:

2

output:

3

result:

ok 1 number(s): "3"

Test #3:

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

input:

3

output:

6

result:

ok 1 number(s): "6"

Test #4:

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

input:

5

output:

26

result:

ok 1 number(s): "26"

Test #5:

score: -100
Wrong Answer
time: 0ms
memory: 3612kb

input:

322

output:

-1431480283

result:

wrong answer 1st numbers differ - expected: '782852421', found: '-1431480283'