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 ;
}

最新文章

  1. JSTL中的fmt标签小例子
  2. Python安装mysql-python错误提示python setup.py egg_info
  3. 简单修改cramfs
  4. paper 68 :MATLAB中取整函数(fix, floor, ceil, round)的使用
  5. jQuery实现图片延迟加载
  6. 利用 Composer 一步一步构建自己的 PHP 框架(三)——设计 MVC
  7. Python学习笔记一--字符串的使用
  8. Sqlserver到处数据到Excel
  9. 衬衫面料品牌:Alumo_衬衫_男装_男装:衬衫、法式衬衫、袖扣领带、西服西裤等男士正装服饰-仕族官网
  10. C#中静态与非静态方法比较【转】
  11. PHP学习过程_Symfony_(3)_整理_十分钟学会Symfony
  12. 转: Ant 脚本的结构化设计
  13. 《Netty5.0架构剖析和源码解读》【PDF】下载
  14. 关于Xcode9.0版本模拟器Reset重置操作变更
  15. 「SCOI2014」方伯伯运椰子 解题报告
  16. cpp typename关键字
  17. RGB格式图像转化为HSV格式
  18. Linux下查看相应端口的进程
  19. 关于js中函数的调用问题
  20. String的疑问

热门文章

  1. MVC+Ext.net零基础学习记录(四)
  2. java.sql.SQLException: Access denied for user &#39;somebody&#39;@&#39;localhost&#39; (using password: YES)
  3. deepin网络加速
  4. html5常用模板下载网站
  5. spring属性注入DI
  6. codeforces 706C C. Hard problem(dp)
  7. 「NOIP2017」「LuoguP3952」 时间复杂度(模拟,栈
  8. javacpp-FFmpeg系列补充:FFmpeg拉流截图实现在线演示demo(视频截图并返回base64图像,支持jpg/png/gif/bmp等多种格式)
  9. BZOJ3065:带插入区间K小值
  10. KCF+Opencv3.0+Cmake+Win10 测试