Codeforces Round #306 (Div. 2)
来源:互联网 发布:苏霍伊和米高扬知乎 编辑:程序博客网 时间:2024/05/01 15:27
题目传送:Codeforces Round #306 (Div. 2)
这次打的很差,有点累,先贴个代码吧。。
A - Two Substrings
#include <map>#include <set>#include <cmath>#include <deque>#include <queue>#include <stack>#include <cstdio>#include <cctype>#include <string>#include <vector>#include <cstdlib>#include <cstring>#include <iostream>#include <algorithm>#define LL long long#define INF 0x7fffffffusing namespace std;char s[100005];int main() {scanf("%s", s);int len = strlen(s);bool ok = false;for(int i = 0; i < len - 1; i ++) {if(s[i] == 'A' && s[i + 1] == 'B') {for(int j = i + 2; j < len - 1; j ++) {if(s[j] == 'B' && s[j + 1] == 'A') {ok = true;}}break;}}for(int i = 0; i < len - 1; i ++) {if(s[i] == 'B' && s[i + 1] == 'A') {for(int j = i + 2; j < len - 1; j ++) {if(s[j] == 'A' && s[j + 1] == 'B') {ok = true;}}break;}}if(ok) puts("YES");else puts("NO");return 0;}
B - Preparing Olympiad
#include <map>#include <set>#include <cmath>#include <deque>#include <queue>#include <stack>#include <cstdio>#include <cctype>#include <string>#include <vector>#include <cstdlib>#include <cstring>#include <iostream>#include <algorithm>#define LL long long#define INF 0x7fffffffusing namespace std;int ans;int n, l, r, x;int a[105];void dfs(int cur, int p, int Max, int Min, int flag, int cnt) {if(cnt >= 2) {if(flag == 1 && p >= l && p <= r && Max != 0 && Max - Min >= x) {ans ++;//cout << Max << " " << Min << endl;//cout << p << " " << cur << endl;}}if(cur >= n) {return ;}dfs(cur + 1, p + a[cur], max(Max, a[cur]), min(Min, a[cur]), 1, cnt + 1);dfs(cur + 1, p, Max, Min, 0, cnt);}int main() {ans = 0;scanf("%d %d %d %d", &n, &l, &r, &x);if(n == 1) {printf("0\n");return 0;}//cout << l << " " << r << endl;for(int i = 0; i < n; i ++) {scanf("%d", &a[i]);}dfs(0, 0, 0, INF, 0, 0);printf("%d\n", ans);return 0;}
C - Divisibility by Eight
#include <map>#include <set>#include <cmath>#include <deque>#include <queue>#include <stack>#include <cstdio>#include <cctype>#include <string>#include <vector>#include <cstdlib>#include <cstring>#include <iostream>#include <algorithm>#define LL long long#define INF 0x7fffffffusing namespace std;char s[1005];int main() {scanf("%s", s);int len = strlen(s);for(int i = 0; i < len; i ++) {if((s[i] - '0') % 8 == 0) {printf("YES\n%d\n", s[i] - '0');return 0;}}for(int i = 0; i < len; i ++) {for(int j = i + 1; j < len; j ++) {int t = (s[i] - '0') * 10 + s[j] - '0';if(t % 8 == 0) {printf("YES\n%d\n", t);return 0;}}}for(int i = 0; i < len; i ++) {for(int j = i + 1; j < len; j ++) {for(int k = j + 1; k < len; k ++) {int t = (s[i] - '0') * 100 + (s[j] - '0') * 10 + s[k] - '0';if(t % 8 == 0) {printf("YES\n%d\n", t);return 0;}}}}printf("NO\n");return 0;}
0 0
- Codeforces Round #306 (Div. 2)
- Codeforces Round #306 (Div. 2)
- Codeforces Round #306 (Div. 2)
- Codeforces Round #306 (Div. 2)
- Codeforces Round #306 (Div. 2)
- Codeforces Round #306 (Div. 2)
- Codeforces Round #306 (Div. 2) A
- Codeforces Round #306 (Div. 2) B
- Codeforces Round #306 (Div. 2) C
- Codeforces Round #306 (Div. 2)_A
- Codeforces Round #306 div 2 solution
- Codeforces Round #306 (Div. 2) A
- Codeforces Round #306 (Div. 2) B(dfs)
- Codeforces Round #306 (Div. 2)_B
- Codeforces Round #306 (Div. 2)_C
- Codeforces Round #306 (Div. 2) (ABCE题解)
- Codeforces Round #306 (Div. 2) D-E
- Codeforces Round #306 (Div. 2) B DFS
- 大家开发完APP有检测过漏洞吗?
- 一键导出excel
- Openstack keystone setup.py和setup.cfg的解析
- python 的sqlite3连接模块用法
- How to get service execuable path
- Codeforces Round #306 (Div. 2)
- 为Runner做一张有质感的图
- 新GRE阅读关于Emily Dickinson 的作品
- Java中的正则表达式中的中文
- Stanford公开课机器学习---week3-1.Logistic Regression 逻辑回归
- IO类
- jQuery的三种$()
- 【扫盲贴!】微信公众平台开发需要懂哪些技术
- mysql导入导出sql文件