Codeforces Round #270
来源:互联网 发布:国外免费wifi软件 编辑:程序博客网 时间:2024/04/29 23:16
A :一个签到的题目,题意懂了就OK
B :贪心的话不难想到坐一次就尽量带上尽可能多的人,而去high楼层的人带上尽可能多的比他low无疑更佳,因此从最高的开始找,依次是1, 1+k, 1+2k.....
C :排序按照姓或名(字典序),如果有与所给顺序匹配的则是YES,反之是NO
代码:
A :
#include<stdio.h>#include<string.h>int prime(int n){ int i; for(i=2;i<=n/2;i++) { if(n%i==0) break; } if(i>n/2&&n!=1) return 1; else return 0;}int main(){ int n,i; scanf("%d",&n); for(i=2;i<=n;i++) { if(prime(i)==0&&prime(n-i)==0) { printf("%d %d\n",i,n-i); break; } } return 0;}
B :
#include<stdio.h>#include<string.h>#include<algorithm>using namespace std;int cmp(int a, int b){ return a > b;}int a[2005];int main(){ int n, k; while(~scanf("%d%d", &n, &k)) { for(int i = 1; i <= n; i++) { scanf("%d", &a[i]); } int ans = 0; sort(a+1, a+1+n, cmp); int x = 1; while(x <= n) { ans += (a[x]-1) * 2; x += k; } printf("%d\n", ans); } return 0;}
C :
#include<cstdio>#include<cstring>#include<cstdlib>#include<iostream>#include<cmath>#include<algorithm>using namespace std;int n,a[100002];char s[100002][2][55],c[55];void fuck(){ int i,x=a[1],y=0; for(i=2;i<=n;i++) { if(strcmp(s[a[i]][1],s[x][y])<0) { printf("NO\n"); return ; } if(strcmp(s[a[i]][0],s[x][y])>0) { x=a[i]; y=0; } else { x=a[i]; y=1; } } printf("YES\n");}int main(){ int i; scanf("%d",&n); for(i=1;i<=n;i++) { scanf("%s%s",s[i][0],s[i][1]); if(strcmp(s[i][0],s[i][1])>0) { strcpy(c,s[i][0]); strcpy(s[i][0],s[i][1]); strcpy(s[i][1],c); } } for(i=1;i<=n;i++) { scanf("%d",&a[i]); } fuck(); return 0;}
0 0
- Codeforces Round #270 Codeforces Round #270
- Codeforces Round #270
- Codeforces Round #270
- Codeforces Round #270 A~D
- 【codeforces】Codeforces Round #363
- Codeforces Round #270 F(高斯消元+XOR)
- Codeforces Round #270(活用prim算法)
- Codeforces Round #270 A.(素数打表)
- 【Codeforces】Codeforces Round #271 div2
- 【CODEFORCES】 Educational Codeforces Round 1
- Codeforces Educational Codeforces Round 5
- Codeforces Round #403 div2 (CodeForces
- Codeforces Round #404 div2 (CodeForces
- Codeforces Educational Codeforces Round 22
- Codeforces Educational Codeforces Round 27
- Codeforces Educational Codeforces Round 27
- Codeforces Educational Codeforces Round 27
- Codeforces Educational Codeforces Round 27
- C++ Primer 学习笔记 整形
- Android开发笔记之文件访问(二)
- 求int 的最大值
- Codeforces 4C-Registration system(map)
- delcookie
- Codeforces Round #270
- UIScrollView的循环滚动相册
- int类型溢出后回环
- java jdbc封装为DAO
- 有符号型和无符号型各种数据类型的溢出问题
- 创建物化视图详解(图解)
- 【BZOJ3224】普通平衡树,SBT和failedSPT
- Android开发性能优化大总结
- C++的右值引用