Codeforces Round #170 (Div. 2)
来源:互联网 发布:c语言getchar位置输入 编辑:程序博客网 时间:2024/04/28 05:53
题目:Codeforces Round #170 (Div. 2)
A : Circle Line
求从起始到目标的最短路,直接累加这一段,跟剩下的取个最小值即可
= = 为了跟wiking大神比速度,手贱WA一次
#include <cstdio>#include <iostream>#include <cstring>#include <algorithm>#include <cmath>using namespace std;int n;int a[110];int main(){ scanf("%d",&n); int total=0; for(int i=1;i<=n;i++) { scanf("%d",&a[i]); total+=a[i]; } int ans=0; int x,y; scanf("%d%d",&x,&y); if(x>y) swap(x,y); for(int i=x;i<y;i++) ans+=a[i]; printf("%d\n",min(ans,total-ans)); return 0;}
B : New Problem
因为是30个串,每个串大小20,所以只有600种可能,枚举的话答案的串顶多也就两个字符,直接暴力
#include <cstdio>#include <iostream>#include <cstring>#include <algorithm>#include <cmath>using namespace std;string s[31];int num[26];int main(){ int n; scanf("%d",&n); memset(num,0,sizeof(num)); for(int i=1;i<=n;i++) { cin>>s[i]; for(int j=0;j<s[i].length();j++) { num[s[i][j]-'a']++; } } char str; int tag=0; for(int i=0;i<26;i++) { if(num[i]==0) { str='a'+i; break; } if(i==25) { tag=1; break; } } if(tag==0) printf("%c\n",str); else { tag=1; string ss; for(int i=0;i<26;i++) { for(int j=0;j<26;j++) { tag=1; ss[0]='a'+i; ss[1]='a'+j; for(int k=1;k<=n;k++) { for(int l=0;l<s[k].length()-2+1;l++) { if(ss[0]==s[k][l]&&ss[1]==s[k][l+1]) { tag=0; break; } } if(tag==0) break; } if(tag) { printf("%c%c\n",ss[0],ss[1]); break; } } if(tag) break; } } return 0;}
C : Learning Languages
图论,并查集,不会。。。。。
D : Set of Points
YY 题 枚举一下不存在的情况,剩下的自己YY一下存在凸的部分 = =
#include <cstdio>#include <iostream>#include <cstring>#include <algorithm>#include <cmath>using namespace std;int main(){ int m,n; scanf("%d%d",&n,&m); if(m==3&&n>=5) { printf("-1\n"); return 0; } __int64 ans=1993522; for(__int64 i=0;i<m;i++) printf("%I64d %I64d\n",i,ans+i*i); for(__int64 i=0;i<n-m;i++) printf("%I64d %I64d\n",i,-ans-i*i); return 0;}
- Codeforces Round #170 (Div. 2)
- Codeforces Round #170 (Div. 2)
- Codeforces Round #170 (Div. 2)
- Codeforces Round #170 (Div. 2)
- Codeforces Round #170 (Div. 2)Tire--KMP
- Codeforces Round #170 (Div. 2) problem B
- Codeforces Round #170 (Div. 2)总结
- Codeforces Round#170(Div 2)C
- Codeforces Round #102 (Div. 2)
- Codeforces Round #103 (Div. 2)
- Codeforces Round #103 (Div. 2)
- Codeforces Round #104 (Div. 2)
- Codeforces Round #105 (Div. 2)
- Codeforces Round #105 (Div. 2)
- Codeforces Round #107 (Div. 2)
- Codeforces Round #108 (Div. 2)
- Codeforces Round #110 (Div. 2)
- Codeforces Round #122 (Div. 2)
- GridView中显示时间日期格式问题
- 进行约束的SQL语句
- Android源码网站
- IteratorIterator类-SPL库
- 二叉树的初始化及遍历
- Codeforces Round #170 (Div. 2)
- uva 324Factorial Frequencies
- spring四种依赖注入方式
- Android推送服务(GCM)----GCM Architectural Overview翻译
- 谈一下自己收集资料和整理资料的经验
- Loadrunner监视Linux系统过程及遇到的问题
- Maven系列— Maven3的安装(windows环境)
- 三层架构中多层的使用关系
- java.sql.SQLNonTransientConnectionException: Database 'TempStatsStore' shutdown. java.sql.SQLExcept