Codeforces Round #313 (Div. 2) A.B,C,D,E Currency System in Geraldion Gerald is into Art Gerald's Hexagon Equivalent Strings
A题,超级大水题,根据有没有1输出-1和1就行了。我沙茶,把%d写成了%n。
B题,也水,两个矩形的长和宽分别加一下,剩下的两个取大的那个,看看是否框得下。
C题,其实也很简单,题目保证了小三角形是正三角形,一个正三角的面积=l*l*(1/2)*cos(30),由于只要算三角形个数,把六边形扩成一个大三角,剪掉三个小三角,除一下系数就没了。就变成了平方相减。
D题,根据定义递归。然后注意奇数就行了。我沙茶,没加第一种判断dfs(a+len,len,b+len) && dfs(a,len,b)。
E题,有思路,没写代码,就是个DP,设当前走到r,c且不经过黑点的方案数为dp[r][c],转移的时候用C(r+c-2,r-1)可以算出从(0,0)点走到(r,c)的方案数,然后减去从之前的黑点走到(r,c)的方案数。
总结,好好读题,仔细敲代码
A题
- #define HDU
- #ifndef HDU
- #include<bits/stdc++.h>
- #else
- #include<cstdio>
- #include<cmath>
- #include<vector>
- #include<map>
- #include<set>
- #include<algorithm>
- #include<cstring>
- #endif // HDU
- using namespace std;
- //const int maxn = 1009;
- //int n;
- //int a[maxn];
- int main()
- {
- #ifdef local
- freopen("in.txt","r",stdin);
- //freopen("out.txt","w",stdout);
- #endif // local
- int t;
- int n;
- while(~scanf("%d",&n)){
- bool flag = ;
- for(int i = ; i < n; i++){
- scanf("%d",&t);
- if(t == ) flag = ;
- }
- if(flag) printf("-1");
- else printf("");
- }
- return ;
- }
- /*
- // for(int i = 0; i < n; i++){
- //}
- scanf("%d",a+i);
- sort(a,a+n);
- if(a[0] == 1 ){
- }else
- */
B题
- #define HDU
- #ifndef HDU
- #include<bits/stdc++.h>
- #else
- #include<cstdio>
- #include<cmath>
- #include<vector>
- #include<map>
- #include<set>
- #include<algorithm>
- //#include<iostream>
- #endif // HDU
- using namespace std;
- //#define local
- #define PY { puts("YES"); return 0; }
- #define PN { puts("NO"); return 0; }
- int main()
- {
- #ifdef local
- freopen("in.txt","r",stdin);
- //freopen("out.txt","w",stdout);
- #endif // local
- int a0,b0;
- scanf("%d%d",&a0,&b0);
- int a1,b1,a2,b2;
- scanf("%d%d%d%d",&a1,&b1,&a2,&b2);
- int t = (a1+a2),t2 = max(b1,b2);
- if((t<=a0 && t2<= b0)|| (t<=b0 && t2<=a0) ) PY;
- t = (a1+b2); t2 = max(b1,a2);
- if((t<=a0 && t2<= b0)|| (t<=b0 && t2<=a0) ) PY;
- t = (b1+a2); t2 = max(a1,b2);
- if((t<=a0 && t2<= b0)|| (t<=b0 && t2<=a0) ) PY;
- t = (b1+b2); t2 = max(a1,a2);
- if((t<=a0 && t2<= b0)|| (t<=b0 && t2<=a0) ) PY;
- PN;
- return ;
- }
C题
- #define HDU
- #ifndef HDU
- #include<bits/stdc++.h>
- #else
- #include<cstdio>
- #include<cmath>
- #include<vector>
- #include<map>
- #include<set>
- #include<algorithm>
- //#include<iostream>
- #endif // HDU
- using namespace std;
- //#define local
- int main()
- {
- #ifdef local
- freopen("in.txt","r",stdin);
- //freopen("out.txt","w",stdout);
- #endif // local
- int a,b,c,d,e,f,g;
- scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f,&g);
- int l = a+b+c;
- int ans = l*l - a*a - c*c - e*e;
- printf("%d",ans);
- return ;
- }
D题
- #define HDU
- #ifndef HDU
- #include<bits/stdc++.h>
- #else
- #include<cstdio>
- #include<cmath>
- #include<vector>
- #include<map>
- #include<set>
- #include<algorithm>
- #include<cstring>
- #endif // HDU
- using namespace std;
- //#define local
- bool dfs(char *a,int len,char *b)
- {
- if(len == ) { return (*a) == (*b); }
- if(memcmp(a,b,len) == ) return true;
- if(len&) return false;
- len >>= ;
- return (dfs(a,len,b+len) && dfs(a+len,len,b))||(dfs(a+len,len,b+len) && dfs(a,len,b));
- }
- const int maxn = +;
- char a[maxn],b[maxn];
- int main()
- {
- #ifdef local
- freopen("in.txt","r",stdin);
- //freopen("out.txt","w",stdout);
- #endif // local
- scanf("%s%s",a,b);
- int len = strlen(a);
- printf("%s\n",dfs(a,len,b)?"YES":"NO");
- return ;
- }
Codeforces Round #313 (Div. 2) A.B,C,D,E Currency System in Geraldion Gerald is into Art Gerald's Hexagon Equivalent Strings的更多相关文章
- 【打CF,学算法——一星级】Codeforces Round #313 (Div. 2) A. Currency System in Geraldion
[CF简单介绍] 提交链接:http://codeforces.com/contest/560/problem/A 题面: A. Currency System in Geraldion time l ...
- Codeforces Round #313 (Div. 2) A. Currency System in Geraldion
A. Currency System in Geraldion Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/co ...
- Codeforces Round #313 (Div. 2) A. Currency System in Geraldion 水题
A. Currency System in Geraldion Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/c ...
- Codeforces Round #313 (Div. 1) B. Equivalent Strings
Equivalent Strings Problem's Link: http://codeforces.com/contest/559/problem/B Mean: 给定两个等长串s1,s2,判断 ...
- Codeforces Round #313 (Div. 2)B.B. Gerald is into Art
B. Gerald is into Art Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/problemset/ ...
- Codeforces Round #313 (Div. 2) D. Equivalent Strings
D. Equivalent Strings Time Limit: 2 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/559/ ...
- Codeforces Round #313 (Div. 1) B. Equivalent Strings DFS暴力
B. Equivalent Strings Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/559 ...
- Codeforces Round #313 (Div. 2) B. Gerald is into Art 水题
B. Gerald is into Art Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/560 ...
- 【打CF,学算法——二星级】Codeforces Round #313 (Div. 2) B. Gerald is into Art(水题)
[CF简单介绍] 提交链接:http://codeforces.com/contest/560/problem/B 题面: B. Gerald is into Art time limit per t ...
随机推荐
- codevs1553 互斥的数
1553 互斥的数
- django后台管理系统(admin)的简单使用
目录 django后台管理系统的使用 检查配置文件 检查根urls.py文件 启动项目,浏览器输入ip端口/admin 如: 127.0.0.1/8000/admin 回车 注册后台管理系统超级管理 ...
- maven工程运行出Unable to compile class for JSP: 错误
使用mvn tomcat:run运行时出现500错误,使用tomcat7再次运行就好了 更新,上面的是在命令行操作的 如果要在idea上面出现错误的话需要在pom.xml上配置下面的语句 org.ap ...
- Jar命令用法
JAR文件 JAR文件 全称:Java Archive File , 意思是Java档案文件.通常JAR文件是一种压缩文件,与常见的ZIP压缩文件兼容,通常被称为JAR包. JAR文件和ZIP文件的区 ...
- JS 对象的操作方法
第一种: 变量名.style.属性: 第二种: 变量名.style[参数]
- JavaScript基础学习日志(1)——属性操作
JS中的属性操作: 属性操作语法 属性读操作:获取 实例:获取Input值 实例:获取select值 字符串连接 属性写操作:修改.添加 实例:修改value值 实例:添加图片的src地址 inner ...
- Kestrel服务器启动并处理Http请求
从Hosting开始 知识点: 1.Kestrel服务器启动并处理Http请求的过程. 2.Startup的作用. 源码飘香: 总结: asp.net core将web开发拆分为多个独立的组件,大 ...
- 关于FutureTask的探索
之前关于Java线程的时候,都是通过实现Runnable接口或者是实现Callable接口,前者交给Thread去run,后者submit到一个ExecutorService去执行. 然后知道了还有个 ...
- D. Restructuring Company 并查集 + 维护一个区间技巧
http://codeforces.com/contest/566/problem/D D. Restructuring Company time limit per test 2 seconds m ...
- Oracle批量SQL之 BULK COLLECT 子句
BULK COLLECT 子句会批量检索结果,即一次性将结果集绑定到一个集合变量中,并从SQL引擎发送到PL/SQL引擎.通常可以在SELECT INTO.FETCH INTO以及RETURNING ...