题目链接:http://codeforces.com/contest/550

A

暴力一发。

代码:

#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string>
#include <string.h>
#include <set>
#include <map>
#include <vector>
#include <algorithm> using namespace std; const int MAXN =100010; char s[MAXN];
int pos1[MAXN];
int pos2[MAXN]; int main()
{
while (cin>>s)
{
int ok1 = 0,ok2 = 0;
int tmp = 0;
int len = strlen(s);
int num1 = 0,num2 = 0; for(int i = 0;i < len - 1;i++)
{
if (s[i] == 'A' && s[i+1]=='B')
{
ok1 = 1;
pos1[num1++] = i;
}
if (s[i] == 'B' && s[i+1]=='A')
{
ok2 = 1;
pos2[num2++] = i;
}
}
int ok=0;
if (ok1 == 1 && ok2 == 1)
{
for(int i=0;i < num1;i++)
{
if(ok) break;
for(int j=0;j < num2;j++)
{
if (abs(pos1[i] - pos2[j]) != 1)
{
ok=1;
break;
}
}
}
}
if (ok) puts("YES");
else puts("NO");
}
return 0;
}

B 再暴力一发

#include <math.h>
#include <limits.h>
#include <complex>
#include <string>
#include <functional>
#include <iterator>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <bitset>
#include <sstream>
#include <iomanip>
#include <fstream>
#include <iostream>
#include <ctime>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <time.h>
#include <ctype.h>
#include <string.h>
#include <assert.h> using namespace std; int n, l, r, X, a[100];
int ans; void rec(int x, int sum, int mn, int mx, int cnt)
{
if (x == n)
{
if ((cnt >= 2) && (sum >= l) && (sum <= r) && (mx - mn >= X)) ans++;
return;
}
rec(x + 1, sum, mn, mx, cnt);
rec(x + 1, sum + a[x], min(mn, a[x]), max(mx, a[x]), cnt + 1);
} int main() { while(~scanf("%d%d%d%d", &n, &l, &r, &X))
{
for (int i = 0; i < n; i++)
scanf("%d", &a[i]);
rec(0, 0, 1e9, -1e9, 0);
printf("%d\n", ans);
}
}

C 再再暴力一发

代码:

#include <math.h>
#include <limits.h>
#include <complex>
#include <string>
#include <functional>
#include <iterator>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <bitset>
#include <sstream>
#include <iomanip>
#include <fstream>
#include <iostream>
#include <ctime>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <time.h>
#include <ctype.h>
#include <string.h>
#include <assert.h> using namespace std; char s [1010]; void solve()
{
int len = strlen(s);
for(int i=0;i<len;i++)
{
if((s[i] - 48) % 8 == 0)
{
puts("YES");
printf("%c\n",s[i]);
return;
}
}
for(int i=0;i<len;i++)
{
for(int j=i+1;j<len;j++)
{
int num = s[i] - 48;
num = num *10 + s[j]-48;
if (num % 8 == 0)
{
puts("YES");
printf("%d\n",num);
return;
}
}
}
for(int i=0;i<len;i++)
{
if (s[i] != '0')
for(int j=i+1;j<len;j++)
for(int k=j+1;k<len;k++)
{
int num = s[i]-48;
num = num*10 + s[j] - 48;
num = num*10 + s[k] - 48;
if (num % 8 == 0)
{
puts("YES");
printf("%d\n",num);
return ;
} } }
puts("NO");
} int main()
{
while (cin>>s)
{
int len = strlen(s);
solve();
}
return 0;
}

Codeforces Round #306 (Div. 2) A B C的更多相关文章

  1. 数学/找规律/暴力 Codeforces Round #306 (Div. 2) C. Divisibility by Eight

    题目传送门 /* 数学/暴力:只要一个数的最后三位能被8整除,那么它就是答案:用到sprintf把数字转移成字符读入 */ #include <cstdio> #include <a ...

  2. DFS Codeforces Round #306 (Div. 2) B. Preparing Olympiad

    题目传送门 /* DFS: 排序后一个一个出发往后找,找到>r为止,比赛写了return : */ #include <cstdio> #include <iostream&g ...

  3. 水题 Codeforces Round #306 (Div. 2) A. Two Substrings

    题目传送门 /* 水题:遍历一边先找AB,再BA,再遍历一边先找BA,再AB,两种情况满足一种就YES */ #include <cstdio> #include <iostream ...

  4. Codeforces Round #306 (Div. 2) E. Brackets in Implications 构造

    E. Brackets in Implications Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/conte ...

  5. Codeforces Round #306 (Div. 2) D. Regular Bridge 构造

    D. Regular Bridge Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/550/pro ...

  6. Codeforces Round #306 (Div. 2) C. Divisibility by Eight 暴力

    C. Divisibility by Eight Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/ ...

  7. Codeforces Round #306 (Div. 2) B. Preparing Olympiad dfs

    B. Preparing Olympiad Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/550 ...

  8. Codeforces Round #306 (Div. 2) A. Two Substrings 水题

    A. Two Substrings Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/550/pro ...

  9. Codeforces Round #306 (Div. 2) 550A Two Substrings

    链接:http://codeforces.com/contest/550/problem/A 这是我第一次玩cf这种比赛,前面做了几场练习,觉得div2的前面几个还是比较水的. 所以看到这道题我果断觉 ...

随机推荐

  1. JDK1.8中的Stream详解

    Stream简介 Stream 作为 Java 8 的一大亮点,它与 java.io 包里的 InputStream 和 OutputStream 是完全不同的概念.它也不同于 StAX 对 XML ...

  2. 一个圆的移动 AE教程 速度曲线调节

    AE里面速度的曲线调节 最终的小效果 两个关键点: 一:速度曲线调节 编辑速度图标,他的曲线是编辑速度的. 二:节点不要用贝塞尔曲线 编辑值图标,就是圆圈的x值y值的曲线.控制位置移动的. 选择一个节 ...

  3. vue工程化

    很多人在玩完了官方文档的小例子之后,又不知道如何下手了.所以我这边帮大家把断层补上.大家首先要把vue的基本语法都熟悉了,然后再来这边学习. 有了前面webpack的铺垫,我们直接从vue的工程化开始 ...

  4. java_String类的功能

    String类使用了final修饰不能被继承 实现类Serializable接口,字符串支持序列化 实现了Comparable接口,字符串可以比较大小 内部定义final char[] value用于 ...

  5. hibernate5.3版本出现hibernate中The server time zone value“乱码”问题的解决办法。

    <!-- 配置关于数据库连接的四个项 driverClass url username password --> <property name="hibernate.con ...

  6. webstorm下开发微信小程序

  7. BZOJ 2502 Luogu P4843 清理雪道 最小流

    题意: 滑雪场坐落在FJ省西北部的若干座山上. 从空中鸟瞰,滑雪场可以看作一个有向无环图,每条弧代表一个斜坡(即雪道),弧的方向代表斜坡下降的方向. 你的团队负责每周定时清理雪道.你们拥有一架直升飞机 ...

  8. [Algorithm] 1. A+B Problem

    Description Write a function that add two numbers A and B. Clarification Are a and b both 32-bit int ...

  9. mysql主从同步,主库宕机解决方案

    链接:https://blog.csdn.net/zfl589778/article/details/51441719

  10. python3.x Day5 面向对象

    类:类是指:对具有相同属性的事物的抽象.蓝图.原型.在类中定义了这些事物都具备的属性和共同的方法. 对象:一个对象就是一个类实例化以后的实例,一个类必须经过实例化后才能在程序中被使用,一个类可以实例化 ...