[CCPC2016]网赛部分比赛代码
来自HDOJ:
/*
━━━━━┒ギリギリ♂ eye!
┓┏┓┏┓┃キリキリ♂ mind!
┛┗┛┗┛┃\○/
┓┏┓┏┓┃ /
┛┗┛┗┛┃ノ)
┓┏┓┏┓┃
┛┗┛┗┛┃
┓┏┓┏┓┃
┛┗┛┗┛┃
┓┏┓┏┓┃
┛┗┛┗┛┃
┓┏┓┏┓┃
┃┃┃┃┃┃
┻┻┻┻┻┻
*/
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <climits>
#include <complex>
#include <cassert>
#include <cstdio>
#include <bitset>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <ctime>
#include <set>
#include <map>
#include <cmath>
using namespace std;
#define fr first
#define sc second
#define cl clear
#define BUG puts("here!!!")
#define W(a) while(a--)
#define pb(a) push_back(a)
#define Rint(a) scanf("%d", &a)
#define Rll(a) scanf("%I64d", &a)
#define Rs(a) scanf("%s", a)
#define Cin(a) cin >> a
#define FRead() freopen("in", "r", stdin)
#define FWrite() freopen("out", "w", stdout)
#define Rep(i, len) for(int i = 0; i < (len); i++)
#define For(i, a, len) for(int i = (a); i < (len); i++)
#define Cls(a) memset((a), 0, sizeof(a))
#define Clr(a, x) memset((a), (x), sizeof(a))
#define Full(a) memset((a), 0x7f7f7f, sizeof(a))
#define lrt rt << 1
#define rrt rt << 1 | 1
#define pi 3.14159265359
#define RT return
#define lowbit(x) x & (-x)
#define onenum(x) __builtin_popcount(x)
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
typedef pair<LL, LL> pll;
typedef map<string, int> msi;
typedef vector<int> vi;
typedef vector<LL> vl;
typedef vector<vl> vvl;
typedef vector<bool> vb; const int maxn = ;
const int maxm = ;
const LL mod = ;
typedef struct Bucket {
LL b[maxm];
}Bucket;
int n;
LL a[maxn];
bool _p[maxm];
LL prime[maxm];
int pcnt;
LL dp[maxn][maxn]; void init() {
Cls(_p); pcnt = ;
For(i, , maxm) {
if(_p[i] == ) {
prime[pcnt++] = i;
for(int j = i * ; j < maxm; j+=i) {
_p[j] = ;
}
}
}
} void gao(int i, LL x) {
for(int j = ; j < pcnt; j++) {
if(x % prime[j]) continue;
int cnt = ;
while(x % prime[j] == ) {
x /= prime[j];
cnt ^= ;
}
dp[i][j] = cnt;
}
} LL quickmul(LL x, LL n, LL mod) {
LL ret = ;
while(n) {
if(n & ) ret = (ret * x) % mod;
x = (x * x) % mod;
n >>= ;
}
return ret;
} int main() {
// FRead();
int T, _ = ;
Rint(T);
init();
W(T) {
Cls(dp);
printf("Case #%d:\n", _++);
Rint(n);
For(i, , n+) {
cin >> a[i];
gao(i, a[i]);
}
int p = ;
Rep(i, pcnt) {
For(j, p, pcnt) {
if(dp[j][i]) {
For(k, i, pcnt) {
swap(dp[j][k], dp[p][k]);
}
break;
}
}
if(!dp[p][i]) continue;
For(j, p+, pcnt) {
if(dp[j][i]) {
For(k, i, pcnt) {
dp[j][k] ^= dp[p][k];
}
}
}
p++;
}
cout << (quickmul(,n-p,mod)-+mod)%mod << endl;
}
RT ;
}
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cassert>
using namespace std;
int s[];
int main(){
int T,n;
int sum,ans,coco;
scanf("%d",&T);
int pp = ;
while(T--){
int maxn = ;
sum = ;
scanf("%d",&n);
for(int i=;i<n;i++){
scanf("%d",&s[i]);
sum +=s[i];
maxn = maxn < s[i] ? s[i] : maxn;
}
ans = sum/;
if(maxn > sum/){
coco = (sum - maxn) * + ;
ans = coco > ans ? ans : coco;
}
printf("Case #%d: %d\n",pp++,ans);
}
}
/*
━━━━━┒ギリギリ♂ eye!
┓┏┓┏┓┃キリキリ♂ mind!
┛┗┛┗┛┃\○/
┓┏┓┏┓┃ /
┛┗┛┗┛┃ノ)
┓┏┓┏┓┃
┛┗┛┗┛┃
┓┏┓┏┓┃
┛┗┛┗┛┃
┓┏┓┏┓┃
┛┗┛┗┛┃
┓┏┓┏┓┃
┃┃┃┃┃┃
┻┻┻┻┻┻
*/
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <climits>
#include <complex>
#include <cassert>
#include <cstdio>
#include <bitset>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <ctime>
#include <set>
#include <map>
#include <cmath>
using namespace std;
#define fr first
#define sc second
#define cl clear
#define BUG puts("here!!!")
#define W(a) while(a--)
#define pb(a) push_back(a)
#define Rint(a) scanf("%d", &a)
#define Rll(a) scanf("%I64d", &a)
#define Rs(a) scanf("%s", a)
#define Cin(a) cin >> a
#define FRead() freopen("in", "r", stdin)
#define FWrite() freopen("out", "w", stdout)
#define Rep(i, len) for(int i = 0; i < (len); i++)
#define For(i, a, len) for(int i = (a); i < (len); i++)
#define Cls(a) memset((a), 0, sizeof(a))
#define Clr(a, x) memset((a), (x), sizeof(a))
#define Full(a) memset((a), 0x7f7f7f, sizeof(a))
#define lrt rt << 1
#define rrt rt << 1 | 1
#define pi 3.14159265359
#define RT return
#define lowbit(x) x & (-x)
#define onenum(x) __builtin_popcount(x)
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
typedef pair<LL, LL> pll;
typedef map<string, int> msi;
typedef vector<int> vi;
typedef vector<LL> vl;
typedef vector<vl> vvl;
typedef vector<bool> vb; const int maxn = ;
char str[maxn];
int len;
int mod(int num) {
int ret = ;
Rep(i, len) {
ret = (int)(((LL)ret * + (str[i] - '')) % num);
}
return ret;
} int main() {
// FRead();
int _ = ;
while(Rs(str)!=EOF) {
printf("Case #%d: ", _++);
len = strlen(str);
int num = ;
if(len <= ) {
Rep(i, len) {
num *= ;
num += str[i] - '';
}
if(num == || num % == ) {
puts("YES");
continue;
}
if(num != || num % != ) {
puts("NO");
continue;
}
}
int t = mod();
if(t == ) puts("YES");
else puts("NO");
}
RT ;
}
/*
━━━━━┒ギリギリ♂ eye!
┓┏┓┏┓┃キリキリ♂ mind!
┛┗┛┗┛┃\○/
┓┏┓┏┓┃ /
┛┗┛┗┛┃ノ)
┓┏┓┏┓┃
┛┗┛┗┛┃
┓┏┓┏┓┃
┛┗┛┗┛┃
┓┏┓┏┓┃
┛┗┛┗┛┃
┓┏┓┏┓┃
┃┃┃┃┃┃
┻┻┻┻┻┻
*/
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <climits>
#include <complex>
#include <cassert>
#include <cstdio>
#include <bitset>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <ctime>
#include <set>
#include <map>
#include <cmath>
using namespace std;
#define fr first
#define sc second
#define cl clear
#define BUG puts("here!!!")
#define W(a) while(a--)
#define pb(a) push_back(a)
#define Rint(a) scanf("%d", &a)
#define Rll(a) scanf("%I64d", &a)
#define Rs(a) scanf("%s", a)
#define Cin(a) cin >> a
#define FRead() freopen("in", "r", stdin)
#define FWrite() freopen("out", "w", stdout)
#define Rep(i, len) for(int i = 0; i < (len); i++)
#define For(i, a, len) for(int i = (a); i < (len); i++)
#define Cls(a) memset((a), 0, sizeof(a))
#define Clr(a, x) memset((a), (x), sizeof(a))
#define Full(a) memset((a), 0x7f7f7f, sizeof(a))
#define lrt rt << 1
#define rrt rt << 1 | 1
#define pi 3.14159265359
#define RT return
#define lowbit(x) x & (-x)
#define onenum(x) __builtin_popcount(x)
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
typedef pair<LL, LL> pll;
typedef map<string, int> msi;
typedef vector<int> vi;
typedef vector<LL> vl;
typedef vector<vl> vvl;
typedef vector<bool> vb; const int maxn = ;
char str[maxn];
int ascii[];
int a[maxn];
int n, q;
int ord;
int dp[maxn];
int s[maxn]; int bs(int ll, int rr, int v) {
while(ll <= rr) {
int mm = (ll + rr) >> ;
if(s[mm] < v) ll = mm + ;
else rr = mm - ;
}
return ll;
} int main() {
// FRead();
int T, _ = ;
Rint(T);
W(T) {
ord = ; q = ;
Rs(str);
memset(ascii, -, sizeof(ascii));
memset(dp, , sizeof(dp));
memset(s, 0x7f7f7f7f, sizeof(s));
printf("Case #%d: ", _++);
n = strlen(str);
Rep(i, n) {
if(ascii[str[i]] == -) {
ascii[str[i]] = ord;
a[q++] = ord++;
}
else {
a[q++] = ascii[str[i]];
}
}
int ans = ;
For(i, , n+) {
dp[i] = bs(, i, a[i]);
s[dp[i]] = min(s[dp[i]], a[i]);
ans = max(ans, dp[i]);
}
printf("%d\n", ans);
}
RT ;
}
[CCPC2016]网赛部分比赛代码的更多相关文章
- 使用pwn_deploy_chroot部署国赛pwn比赛题目
目录 使用pwn_deploy_chroot部署国赛pwn比赛题目 一.前言 二.Docker 三.部署镜像 四.pwn_deploy_chroot 五.check && exp 六. ...
- 团体程序设计天梯赛(CCCC) L3019 代码排版 方法与编译原理密切相关,只有一个测试点段错误
团体程序设计天梯赛代码.体现代码技巧,比赛技巧. https://github.com/congmingyige/cccc_code
- 阿里天池 NLP 入门赛 TextCNN 方案代码详细注释和流程讲解
thumbnail: https://image.zhangxiann.com/jung-ho-park-HbnqEhMBpPM-unsplash.jpg toc: true date: 2020/8 ...
- hihoCoder1388 Periodic Signal(2016北京网赛F:NTT)
题目 Source http://hihocoder.com/problemset/problem/1388 Description Profess X is an expert in signal ...
- [JS]东方财富网财经数据汇总代码示例
把握全球金融状况 一个页面看全球金融,感觉不错 再加上以前做的,读取显示 新浪7*24财经直播数据页面 那看得就更舒服了 下面是 新浪7*24财经直播数据 代码地址: http://www.cnblo ...
- hdu4740【杭州网赛、模拟、有点搜索?】
当时看了这题就感觉so easy... 本来不想写的,后来感觉是不是可以练一下搜索水平.. 比赛时有人过了就没写. 比赛完了写一下. 实现还不是那么顺利, 囧 本来自己以为这题能练下搜 ...
- 2018宁夏邀请赛网赛 I. Reversion Count(java练习题)
题目链接 :https://nanti.jisuanke.com/t/26217 Description: There is a positive integer X, X's reversion c ...
- 2013杭州网赛 1001 hdu 4738 Caocao's Bridges(双连通分量割边/桥)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4738 题意:有n座岛和m条桥,每条桥上有w个兵守着,现在要派不少于守桥的士兵数的人去炸桥,只能炸一条桥 ...
- HDU 4746 HDOJ Mophues 2013杭州网赛I题
比赛的时候就预感到这题能出,但是会耗时比较多.结果最后是出了,但是有更简单的题没出. 是不是错误的决策呢?谁知道呢 题目意思: 定义f(x) = x分解质因数出来的因子个数 如 x = p0 * p0 ...
随机推荐
- Asp.net 导入Excel(服务器不带Office)
#region 把excel文件转换为DataSet. /// <summary> /// 把excel文件转换为DataSet. /// </summary> /// < ...
- javascript中继承(二)-----借用构造函数继承的个人理解
本人目录如下: 零.寒暄&回顾 一,借用构造函数 二.事件代理 三,call和apply的用法 四.总结 零.寒暄&回顾 上次博客跟大家分享了自己对原型链继承的理解,想看的同学欢迎猛击 ...
- html5离线存储
为了提升Web应用的用户体验,我们在做网站或者webapp的时候,经常需要保存一些内容到本地.例如,用户登录token,或者一些不经常变动的数据. 随着HTML5的到来,出现了诸如AppCache.l ...
- codeforces #232 div2 解题报告
A:简单题:我们可以把点换成段处理,然后枚举段看是否被霸占了: #include<iostream> #include<]; ]=; ;i<=n;i++) { ...
- 在JavaScript中实现yield,实用简洁实现方式。
原题还是老赵的: http://blog.zhaojie.me/2010/06/code-for-fun-iterator-generator-yield-in-javascript.html 原以为 ...
- 将HTMLCollection/NodeList/伪数组转换成数组
这里把符合以下条件的对象称为伪数组(ArrayLike) 1,具有length属性 2,按索引方式存储数据 3,不具有数组的push,pop等方法 如 1,function内的arguments . ...
- CF444C DZY Loves Colors
考试完之后打的第一场CF,异常惨烈呀,又只做出了一题了.A题呆滞的看了很久,领悟到了出题者的暗示,应该就是两个点的时候最大吧,不然的话这题肯定特别难敲,YY一发交上去然后就过了.然后就在不停地YY B ...
- SQL注入攻击
SQL注入攻击是黑客对数据库进行攻击的常用手段之一.随着B/S模式应用开发的发展,使用这种模式编写应用程序的程序员也越来越多.但是由于程序员的水平及经验也参差不齐,相当大一部分程序员在编写代码的时候, ...
- NPOI之Excel——合并单元格、设置样式、输入公式
首先建立一个空白的工作簿用作测试,并在其中建立空白工作表,在表中建立空白行,在行中建立单元格,并填入内容: //建立空白工作簿 IWorkbook workbook = new HSSFWorkboo ...
- BFS+贪心 HDOJ 5335 Walk Out
题目传送门 /* 题意:求从(1, 1)走到(n, m)的二进制路径值最小 BFS+贪心:按照标程的作法,首先BFS搜索所有相邻0的位置,直到1出现.接下去从最靠近终点的1开始, 每一次走一步,不走回 ...