Codeforces Round #313
来源:互联网 发布:会声会影软件多大 编辑:程序博客网 时间:2024/05/02 13:19
A. Gerald's Hexagon告诉你一个6边型的边长,求这个6边型是有多少个小三角形组成的。模拟一下。
#include <cstdio>#include <cstring>int main(){ int a[10]; for(int i = 1; i <= 6; i++) scanf("%d", &a[i]); int ans = 0; if(a[2] == a[6]) { int k = 1; for(int i = 1; i <= a[1]; i++) { k += 2; } for(int i = 1; i <= a[2]; i++) { ans += k; k += 2; } k = 1; for(int i = 1; i <= a[4]; i++) { k += 2; } for(int i = 1; i <= a[3]; i++) { ans += k; k += 2; } } else if(a[2] < a[6]) { int k = 1; for(int i = 1; i <= a[1]; i++) { k += 2; } for(int i = 1; i <= a[2]; i++) { ans += k; k += 2; } k--; for(int i = 1; i <= a[6]-a[2]; i++) ans += k; k = 1; for(int i = 1; i <= a[4]; i++) { k += 2; } for(int i = 1; i <= a[5]; i++) { ans += k; k += 2; } } else { int k = 1; for(int i = 1; i <= a[1]; i++) { k += 2; } for(int i = 1; i <= a[6]; i++) { ans += k; k += 2; } k--; for(int i = 1; i <= a[2]-a[6]; i++) ans += k; k = 1; for(int i = 1; i <= a[4]; i++) { k += 2; } for(int i = 1; i <= a[3]; i++) { ans += k; k += 2; } } printf("%d\n", ans); return 0;}B. Equivalent Strings给你2个字符串,判断是否相等,相等的定义是a字符串分成2段相同长度的子串,b相同,如果a1==b2&&a2==b2或者a1==b2&&a2==b1,暴力递归判断即可。
#include <cstdio>#include <cstring>char ss1[200010];char ss2[200010];int dp[200010*4][2];bool ok(int s1, int e1, int s2, int e2){ int i, k; for(i = s1, k = s2; i <= e1; i++, k++) if(ss1[i] != ss2[k]) break; if(i > e1) return true; return false;}bool dfs(int s1, int e1, int s2, int e2, int l){ if(s1 == e1) return ss1[s1] == ss2[s2]; if(l&1) return ok(s1, e1, s2, e2); bool b = dfs(s1, (s1+e1)/2, s2, (s2+e2)/2, l/2)&&dfs((s1+e1)/2+1, e1, (s2+e2)/2+1, e2, l/2); if(b) return true; b = dfs(s1, (s1+e1)/2, (s2+e2)/2+1, e2, l/2)&&dfs((s1+e1)/2+1, e1, s2, (s2+e2)/2, l/2); if(b) return true; return false;}int main(){ scanf("%s %s", ss1, ss2); int n = strlen(ss1); memset(dp, -1, sizeof(dp)); if(dfs(0, n-1, 0, n-1, n)) puts("YES"); else puts("NO"); return 0;}C. Gerald and Giant Chess一个矩阵,有一些障碍点,问你从左上角走到右下角有多少种方案。状态压缩DP
0 0
- Codeforces Round 313(div1)
- Codeforces Round #313
- Codeforces Round #313 (Div. 2)
- Codeforces Round #313 (Div. 2)
- Codeforces Round #313 (Div. 2)
- Codeforces Round #313 (Div. 2)
- Codeforces Round #313 (Div. 2)
- Codeforces Round 313 找规律
- Codeforces Round 313 div2 题解
- 【codeforces】Round #313 (Div. 2)
- Codeforces Round #313 (Div. 2)
- Codeforces Round #313 (Div. 2)
- Codeforces Round #313 (Div. 1)
- 【codeforces】Codeforces Round #363
- Codeforces Round #313 (Div. 2) C
- Codeforces Round #313 (Div. 2) ABC
- Codeforces Round #313 (Div. 2) (ABCDE题解)
- Codeforces Round #313 (Div. 2) 解题报告
- POJ 3040 Allowance 贪心
- HIVE环境配置
- Tomcat addWebapp()方法和addContext()方法
- Codeforces Round #300
- Codeforces Round #301
- Codeforces Round #313
- maven打包源代码到仓库
- Codeforces Round #276
- Codeforces Round #244
- CodeMirror简单使用
- SpringMVC整合Freemarker
- Maven项目使用Jetty插件
- WIN8下RabbitMQ安装
- POJ 2566 Bound Found two pointers