Codeforces Round #322 (Div. 2)
2015-10-26 21:21
411 查看
【A. Vasya the Hipster】
【B. Luxurious Houses】
【C. Developing Skills】
【D. Three Logos 】
简单的分类讨论
【E. Kojiro and Furrari】
【F.Zublicanes and Mumocrates】
#include <iostream> #include <cstdio> #include <algorithm> #include <string> #include <cmath> #include <cstring> #include <queue> #include <set> #include <map> #include <vector> using namespace std; typedef long long ll; const int N = 1e5+10; int n, m; int main() { while(~scanf("%d%d", &n, &m)) { if(n < m) swap(n, m); printf("%d %d\n", m, (n - m)/2); } return 0; }
【B. Luxurious Houses】
#include <iostream> #include <algorithm> #include <cstdio> #include <cstring> #include <string> using namespace std; #define inf 100005 int p[inf],res[inf]; int main() { int n; scanf("%d",&n); for(int i=0;i<n;i++) { scanf("%d",&p[i]); } int maxn=p[n-1]; res[n-1]=0; for(int i=n-2;i>=0;i--) { if(maxn<p[i]) { res[i]=0; maxn=p[i]; } else { res[i]=maxn-p[i]+1; } } for(int i=0;i<n;i++) { if(i!=n-1) printf("%d ",res[i]); else printf("%d\n",res[i]); } return 0; }
【C. Developing Skills】
#include <iostream> #include <cstdio> #include <algorithm> #include <string> #include <cmath> #include <cstring> #include <queue> #include <set> #include <map> #include <vector> using namespace std; typedef long long ll; const int N = 1e5+10; int n, k; int b ; int main() { while(~scanf("%d%d", &n, &k)) { int ans = 0, tmp = 0; for(int i = 0, a; i < n; i++) { scanf("%d", &a); ans += a / 10; if((a % 10) == 0) b[i] = 0; else { b[i] = (a / 10 + 1) * 10 - a; a = (a / 10 + 1) * 10; } tmp += (100 - a) / 10; } sort(b, b + n); for(int i = 0; i < n; i++) { if(b[i] == 0) continue; if(b[i] > k) break; ans++, k -= b[i]; } k /= 10; ans += min(k, tmp); printf("%d\n", ans); } return 0; }
【D. Three Logos 】
简单的分类讨论
#include <iostream> #include <algorithm> #include <cstdio> #include <cstring> #include <math.h> #include <string> using namespace std; char s[200][200]; int main() { int x1,y1,x2,y2,x3,y3,ai,bi; scanf("%d%d",&ai,&bi); x1=max(ai,bi),y1=min(ai,bi); scanf("%d%d",&ai,&bi); x2=max(ai,bi),y2=min(ai,bi); scanf("%d%d",&ai,&bi); x3=max(ai,bi),y3=min(ai,bi); int ans=x1*y1+x2*y2+x3*y3; int a=(int)sqrt(ans*1.0); int b=max(max(max(x1,y1),max(x2,y2)),max(x3,y3)); if(a*a!=ans || b>a) printf("-1\n"); else { int resx1=a-x1; int resy1=a-y1; for(int i=0;i<x1;i++) { for(int j=0;j<y1;j++) { s[i][j]='A'; } } if(resx1==0) { int f1=0,f2=0; if(x2==a && x3==a && y2+y3==resy1) { for(int i=0;i<a;i++) { for(int j=y1;j<y1+y2;j++) s[i][j]='B'; for(int j=y1+y2;j<y1+y2+y3;j++) s[i][j]='C'; } printf("%d\n",a); for(int i=0;i<a;i++) printf("%s\n",s[i]); return 0; } int hx1=0,hx2=0; if(x2==resy1) hx1=y2; else if (y2==resy1) hx1=x2; if(x3==resy1) hx2=y3; else if(y3==resy1) hx2=x3; if(hx1==0 || hx2==0) { printf("-1\n"); return 0; } else { for(int j=y1;j<a;j++) { for(int i=0;i<hx1;i++) s[i][j]='B'; for(int i=hx1;i<a;i++) s[i][j]='C'; } printf("%d\n",a); for(int i=0;i<a;i++) printf("%s\n",s[i]); return 0; } } else { if(x3==a && y3==resy1 && ((x2==y1 && y2==resx1) || (x2==resx1 && y2==y1))) { for(int i=0;i<a;i++) for(int j=y1;j<a;j++) s[i][j]='C'; for(int i=x1;i<a;i++) for(int j=0;j<y1;j++) s[i][j]='B'; printf("%d\n",a); for(int i=0;i<a;i++) printf("%s\n",s[i]); return 0; } else if(x3==a &&y3==resx1 && ((x2==x1&&y2==resy1) || (x2==resy1&&y2==x1))) { for(int i=0;i<x1;i++) for(int j=y1;j<a;j++) s[i][j]='B'; for(int i=x1;i<a;i++) for(int j=0;j<a;j++) s[i][j]='C'; printf("%d\n",a); for(int i=0;i<a;i++) printf("%s\n",s[i]); return 0; } else if(x2==a &&y2==resx1 && ((x3==resy1&&y3==x1) || (x3==x1&&y3==resy1))) { for(int i=x1;i<a;i++) for(int j=0;j<a;j++) s[i][j]='B'; for(int i=0;i<x1;i++) for(int j=y1;j<a;j++) s[i][j]='C'; printf("%d\n",a); for(int i=0;i<a;i++) printf("%s\n",s[i]); return 0; } else if(x2==a &&y2==resy1 &&((x3==resx1&&y3==y1) || (x3==y1&&y3==resx1))) { for(int i=0;i<a;i++) for(int j=y1;j<a;j++) s[i][j]='B'; for(int i=x1;i<a;i++) for(int j=0;j<y1;j++) s[i][j]='C'; printf("%d\n",a); for(int i=0;i<a;i++) printf("%s\n",s[i]); return 0; } else { printf("-1\n"); return 0; } } } return 0; }
【E. Kojiro and Furrari】
【F.Zublicanes and Mumocrates】
相关文章推荐
- leetcode之路046 Permutations
- pygame编写的坦克游戏(六)
- UITableView 编辑
- Python中的正则表达式
- 设计模式-23种参考模式
- C#-委派和事件
- hdu 1019 Least Common Multiple【gcd】
- UIImage剪切图片为自定义大小
- 解决方案--gloox源码编译错误
- 解决方案--gloox源码编译错误
- 传递正能量-献给默默追梦的人
- WebSocket形象理解
- 单片机TM4C123学习(一):GPIO模块的应用
- C#-XML
- 测试-软件测试各阶段-摘
- C#-vs2012学习笔记-惊奇于vs的强大和便利
- MVC框架-.net-摘
- C#-VS发布网站-摘
- C#-接口
- 10.多媒体