题目连接:Codeforces 444B DZY Loves FFT
题目大意:根据题目的算法生成a,b数组,然后对于每个长度的l,求a[i]*b[l-i]的最大值。
解题思路:概率问题,枚举前30大的数,如果有就可以直接输出答案,如果没有,就暴力枚举b数组为1的位置找最大值。
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
const int maxn = 1e5;
const int s = 30;
int n, d, x, rec[maxn+5];
int np, pos[maxn+5];
int a[maxn+5], b[maxn+5];
int get_next () {
return x = (37LL * x + 10007) % 1000000007;
}
void init_table () {
for (int i = 0; i < n; i++)
a[i] = i + 1;
for (int i = 0; i < n; i++)
swap(a[i], a[get_next() % (i+1)]);
for (int i = 0; i < n; i++)
b[i] = (i < d ? 1 : 0);
for (int i = 0; i < n; i++)
swap(b[i], b[get_next() % (i+1)]);
}
void init_pos () {
np = 0;
for (int i = 0; i < n; i++) {
if (b[i])
pos[np++] = i;
}
for (int i = 0; i < n; i++)
rec[a[i]] = i;
}
int main () {
scanf("%d%d%d", &n, &d, &x);
init_table();
init_pos();
for (int i = 0; i < n; i++) {
bool flag = true;
for (int j = n; j >= n-s; j--) {
if (rec[j] <= i && b[i-rec[j]]) {
flag = false;
printf("%d\n", j);
break;
}
}
if (flag) {
int ans = 0;
for (int j = 0; j < np && pos[j] <= i; j++) {
ans = max(ans, a[i-pos[j]]);
}
printf("%d\n", ans);
}
}
return 0;
}
分享到:
相关推荐
Codeforces - 1107B. Digital root & 1107C. Brutality(规律 & 贪心)Codeforces - 1107B.
Codeforces 1105B - Zuhair and Strings 测试点37个(全)
Codeforces 题库 101-200 共~500题 codeforces.com版权所有。 程序可提交至该网站评测。
Codeforces 题库 001-100 共~500题 codeforces.com版权所有。 程序可提交至该网站评测。
codeforces编程网站预测分数插件
使用于Google Chrome的Codeforces Enhancer 1.1.2插件安装包。 版本:codeforces enhancer 1.1.2 使用浏览器:Google Chrome
Codeforces 185A - Plant 全测试点49个
codeforces 19 E Fairy 一道比较难的题目的解题报告 推荐阅读
Codeforces global round 10 codes
Codeforces round 678 division 2 codes
Some of the Codeforces problems codes
lucifer1004大佬的博客cf上分攻略故里大佬的githubcf思维题刷题数:44- (1421)codeforces 676 div2 A,B done
Codeforces round 678 D2_Codeforces_源码
一个Codeforces、牛客竞赛、AtCoder平台的编程竞赛查询插件,ACMer必备.zip
打codeforces的神器
codeforces-js Codeforces JS
接受串子-接受字符串相等-接受Codeforces回合#684(Div.2) 2/6 1440A-购买琴弦-接受1440B -中位数的总和-已接受1440C1-二进制表(简易版)-已接受1440C2-二进制表(硬版)-已接受 Codeforces回合#683(分区2) 1/...
Codeforces Round #723 (Div. 2).md
使用 C# + WPF 开发 --- 还在发愁打了那么多场比赛都没有进入首页么? 还在为了前 5 的 hacker 名额阅读千份代码么? 是的,你没有看错! 这是一个 Edu & Div.3 轮 Open hacking 错误代码自动查找器!...
PDF-CodeForces问题 PDF文件中的CodeForces问题 利用CodeForces提取在这个库中的文件 ,文件夹名代表来自CodeForces网址contests`的ID,每个文件夹包含比赛的问题。 有关CodeForces竞赛的疯狂事实 CodeForces上有937...