CCPC吉林站
A.The Fool
#include <bits/stdc++.h>
using namespace std; inline int read()
{
int x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
} /********************************************************************/ int main(){
int t; t = read();
int cnt = ;
while(t--){
cnt++;
int n; n = read();
int last = ;
int ans = ;
for(int i = ;i <= n;i = last){
int j = n/(n/i);
ans += (j-i+)*(n/i);
last = j+;
}
if(n&) printf("Case %d: odd\n", cnt);
else printf("Case %d: even\n", cnt);
}
return ;
}
B.The World
模拟
C.Justice
//似乎卡过去了,可能需要更优化 #include <bits/stdc++.h>
using namespace std; inline int read()
{
int x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
} /********************************************************************/ const int maxn = 1e5+; struct node{
int id;
int val;
vector<int>son;
}now; vector<node>a;
int num[maxn]; bool cmp(node x, node y){
return x.val < y.val;
} int main(){
int t = read();
int cnt = ;
while(t--){ memset(num, , sizeof(num));
a.clear();
cnt++;
int n = read();
for(int i = ;i <= n;i++){
now.val = read();
now.id = i;
now.son.clear();
a.push_back(now);
} printf("Case %d: ", cnt);
if(n == ){ printf("NO\n"); continue;}
bool ok = true;
sort(a.begin(), a.end(), cmp);
while(ok){
//sort(a.begin(), a.end(), cmp);
if(a.size() == ) break;
if(a[].val == && a[].val == ) break;
ok = false;
vector<node>::iterator it = a.end()-;
for(;it != a.begin();it--){
if((*it).val == ) continue;
if((*it).val == (*(it-)).val){
ok = true;
vector<node>::iterator it1 = it-;
int itlen = (*it).son.size();
for(int j = ;j < itlen;j++){
(*it1).son.push_back((*it).son[j]);
}
(*it1).son.push_back((*it).id);
(*it1).val--;
/*
sort((*it1).son.begin(), (*it1).son.end());
(*it1).son.erase(unique((*it1).son.begin(), (*it1).son.end()), (*it1).son.end());
*/
a.erase(it);
it++;
}
if(a.size() == ) break;
}
sort(a.begin(), a.end(), cmp);
}
/*
for(int i = 0; i<a.size();i++){
cout << i+1 << " : " << a[i].val << endl;
}
*/
if(a[].val == && a[].val == ){
printf("YES\n");
int valen = a[].son.size();
num[a[].id] = ;
for(int i = ;i < valen;i++){
num[a[].son[i]] = ;
}
for(int i = ;i <= n;i++)
printf("%d", num[i]);
printf("\n");
}
else printf("NO\n"); }
return ;
}
CCPC吉林站的更多相关文章
- 2018 CCPC 吉林站 H Lovers
2018 CCPC 吉林站 H Lovers 传送门:https://www.spoj.com/problems/LIS2/en/ 题意: q次操作 1.将第l~r个数的左边和和右边都加上一个数d, ...
- 2018年9月22日CCPC吉林站参赛总结
发现思维题是硬伤,代码能力是硬伤,对知识点的理解不深刻是硬伤 接下来要做的就是 1.熟悉每一个知识点,把每一个知识点和实现它的代码联系在一起学习 2.多见题,看看他们是怎么考察这些知识点的,等比赛的时 ...
- 2018 CCPC 吉林站 H Lovers || HDU 6562 (线段树哦)
http://acm.hdu.edu.cn/showproblem.php?pid=6562 题意: q次操作 1.将第l~r个数的左边和和右边都加上一个数d, 使得这个数变成 dsiddsid的形式 ...
- ccpc杭州站 赛后总结
Ccpc杭州站赛后总结 2017年11月4号五号,我参加了ccpc杭州站的比赛,我的队友是聂少飞和王艳,在4号一点半,举行了比赛开幕式,听着教练代表的发言,听着参赛选手代表的发言,听着志愿者的发言,都 ...
- 2018 CCPC 桂林站(upc复现赛)补题
2018 CCPC 桂林站(upc复现赛)补题 G.Greatest Common Divisor(思维) 求相邻数的差值的gcd,对gcd分解素因子,对所有的素因子做一次遍历,找出最小答案. 几个样 ...
- 2021 CCPC 威海站 VP记录(题解)
2021 CCPC 威海站 VP记录(题解) 题目顺序为vp时开题顺序: A - Goodbye, Ziyin! 签到,连边数小于等于2的可以作为二叉树根,若有大于4的直接输出0. code: voi ...
- HDU 6240 Server(2017 CCPC哈尔滨站 K题,01分数规划 + 树状数组优化DP)
题目链接 2017 CCPC Harbin Problem K 题意 给定若干物品,每个物品可以覆盖一个区间.现在要覆盖区间$[1, t]$. 求选出来的物品的$\frac{∑a_{i}}{∑b_ ...
- 2017 CCPC 哈尔滨站 题解
题目链接 2017 CCPC Harbin Problem A Problem B Problem D Problem F Problem L 考虑二分答案. 设当前待验证的答案为x 我们可以把第二 ...
- 2016 CCPC 杭州站 小结
5题倒数第一,铜……(我就知道我们很稳!!!哼!! 这一次心态完全爆炸 开场我就没有按照平时的顺序读题 然后zr的A题wa 我F题T xl说B是一个最小生成树,又说是最小树形图,不会写 K题完全没思路 ...
随机推荐
- LightOJ - 1287 Where to Run —— 期望、状压DP
题目链接:https://vjudge.net/problem/LightOJ-1287 1287 - Where to Run PDF (English) Statistics Forum T ...
- centos7 永久修改主机名
hostnamectl set-hostname xxx 一劳永逸,永绝后患
- Strom 消息处理机制 中英对照翻译 (Storm如何保证消息被完全处理)
官方链接: http://storm.incubator.apache.org/documentation/Guaranteeing-message-processing.html What does ...
- 2017SN多校D1T2 note:dp
题意: 给你一个长度为n的字符串s,并且告诉你有m对字母不能相邻,问你最少在s中取出多少个字符能够使这个字符串合法. 题解: 表示状态: dp[i] = max num of letters 考虑到第 ...
- 在eclipse创建Maven工程修改默认JRE
1. 打开Maven安装目录的setting.xml文件 2.找到profiles标签 3.加入下面配置即可 <profile> <id>jdk-1.8</id&g ...
- rust borrow and move
extern crate core; #[deriving(Show)] struct Foo { f : Box<int> } fn main(){ let mut a = Foo {f ...
- codeforces 569C C. Primes or Palindromes?(素数筛+dp)
题目链接: C. Primes or Palindromes? time limit per test 3 seconds memory limit per test 256 megabytes in ...
- logistic function 和 sigmoid function
简单说, 只要曲线是 “S”形的函数都是sigmoid function: 满足公式<1>的形式的函数都是logistic function. 两者的相同点是: 函数曲线都是“S”形. ...
- Can't load AMD 64-bit .dll on a IA 32-bit platform错误
将tomcat的bin目录下的tcnative-1.dll文件删除.就可以了.
- AndyQsmart ACM学习历程——ZOJ3872 Beauty of Array(递推)
Description Edward has an array A with N integers. He defines the beauty of an array as the summatio ...