Strange ClassTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 74Accepted Submission(s): 60
Problem Description
In Vivid’s school, there is a strange class(SC). In SC, the students’ names are very strange. They are in the same format:(a,b,c must not be the same with each other). For example studens whose names are“abc”,”ddppqq” are in SC, however studens whose names are “aaa”,“ab”,”ddppqqq” are not in SC.Vivid makes friends with so many students, he wants to know who are in SC.
Input
There are multiple test cases (about 10), each case will give a string S which is the name of Vivid’s friend in a single line.Please process to the end of file.[Technical Specification].|S| indicates the length of S.S only contains lowercase letter.
Output
For each case, output YES if Vivid’s friend is the student of SC, otherwise output NO.
Sample Input
abcbc
Sample Output
YESNO
Source
很猥琐的一道题
AC代码:
#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#define LL long long#define INF 0x7fffffffusing namespace std;char str[350];int main() {while(scanf("%s", str) != EOF) {int len = strlen(str);if(len <= 2 || len % 3 != 0 || str[0] == str[len – 1]) {printf("NO\n");continue;}int a[5] = {0, 0, 0};int sum = 0;char cur = str[0];for(int i = 0; i < len; i++) {if(str[i] == cur) a[sum]++;else {sum++;a[sum] ++;cur = str[i];}}//printf("%d %d %d %d\n", a[0], a[1], a[2], sum);int tmp = len / 3;if((len % 3 == 0) && sum == 2 && a[0] == tmp && a[1] == tmp && a[2] == tmp) printf("YES\n");else printf("NO\n");}return 0;}
GunnerTime Limit: 8000/4000 MS (Java/Others)Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 157Accepted Submission(s): 85
Problem Description
Long long ago, there is a gunner whose name is Jack. He likes to go hunting very much. One day he go to the grove. There arebirds andtrees. Thebird stands on the top of thetree. The trees stand in straight line from left to the right. Every tree has its height. Jack stands on the left side of the left most tree. When Jack shots a bullet in height H to the right, the bird which stands in the tree with heightwill falls.Jack will shot many times, he wants to know how many birds fall during each shot.a bullet can hit many birds, as long as they stand on the top of the tree with height of.
Input
There are multiple test cases (about 5), every case givesin the first line,indicates there aretrees andmeans Jack will shottimes.In the second line, there arewhich describes the height of the trees.In the third line, there are m numberswhich describes the height of the Jack’s shots.Please process to the end of file.[Technical Specification]All inputs are integers.
Output
For each, output an integer in a single line indicates the number of birds Jack shot down.
Sample Input
4 31 2 3 41 1 4
Sample Output
101
Hint
Huge input, fast IO is recommended.
Source
卡输入,要快速读入,,不过貌似不写快速读入也行╮(╯▽╰)╭,心累啊,我还多交了一遍
AC代码:
#include <cstdio>#include <cstring>#include <algorithm>#include <cctype>#include <map>using namespace std;int n, m;inline int readint() {char c = getchar();while(!isdigit(c)) c = getchar();int x = 0;while(isdigit(c)){x = x * 10 + c – '0';c = getchar();}return x; }int buf[10];inline void writeint(int i) {int p = 0;if(i == 0) {p++;buf[0] = 0;}else while(i){buf[p++] = i % 10;i /= 10;}for(int j = p-1; j >= 0; j–) putchar('0' + buf[j]); } int main() {while(scanf("%d %d", &n, &m) != EOF) {map<int, int> mp;for(int i = 0; i < n; i++) {int t = readint();mp[t] ++;}for(int i = 0; i < m; i++) {int t = readint();//printf("%d\n", mp[t]);writeint(mp[t]);putchar(10);mp[t] = 0;}}return 0;}
思念是一种幸福的忧伤,是一种甜蜜的惆怅,是一种温馨的痛苦;