[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 ...
随机推荐
- sqlserver 查询库中有多少张表
表数目:select count(1) from sysobjects where xtype='U' 视图数::select count(1) from sysobjects where xtype ...
- python实现web分页日志查看
当我们维护一个网站时,无论前台还是后台,经常会出现各种个样的问题.有时候问题很难直观的发现,这个时候只能查看各种日志来跟踪问题.但是查看日志有各种个样的问题.首先,要用各种工具登陆到服务器,这个有时候 ...
- [geeksforgeeks] Bottom View of a Binary Tree
http://www.geeksforgeeks.org/bottom-view-binary-tree/ Bottom View of a Binary Tree Given a Binary Tr ...
- rpc 小例子
RpcFramework /* * Copyright 2011 Alibaba.com All right reserved. This software is the * confidential ...
- 《暗黑世界GM管理后台系统》部署+功能说明文档
http://www.9miao.com/product-10-1073.html <暗黑世界GM管理后台系统>部署+功能说明文档 <暗黑世界GM管理后台系统>部署+功能说明文 ...
- JQuery拾遗
1.关于JQuery的animate,可以操作background么? 答:如果是单纯的JQuery不可以,需要引入JQuery的ui核心库.否则只支持宽高.透明度.上下左右位置的变化. 2.能否说一 ...
- HDU 3998 Sequence (最长上升子序列+最大流)
参考链接:http://www.cnblogs.com/gentleh/archive/2013/03/30/2989958.html 题意:求一个序列的最长上升子序列,及其个数(注意:两个最长上升子 ...
- Android 检查设备是否存在 导航栏 NavigationBar
尊重原创.尊重作者,转载请标明出处: http://blog.csdn.net/lnb333666/article/details/41821149 目前也没有可靠的方法来检查设备上是否有导航栏.可以 ...
- java基础知识回顾之抽象类
/* 抽象类: 抽象:笼统,模糊,看不懂!不具体. 特点: 1,方法只有声明没有实现时,该方法就是抽象方法,需要被abstract修饰. 抽象方法必须定义在抽象类中.该类必须也被abstract修饰. ...
- [你必须知道的.NET]第三十一回,深入.NET 4.0之,从“新”展望
发布日期:2009.05.22 作者:Anytao © 2009 Anytao.com ,Anytao原创作品,转贴请注明作者和出处. /// <summary> /// 本文开始,将以& ...