A. Encoding

Problem Description

Given a string containing only ‘A’ - ‘Z’, we could encode it using the following method:

  1. Each sub-string containing k same characters should be encoded to “kX” where “X” is the only character in this sub-string.

  2. If the length of the sub-string is 1, ‘1’ should be ignored.

Input

The first line contains an integer N (1 <= N <= 100) which indicates the number of test cases. The next N lines contain N strings. Each string consists of only ‘A’ - ‘Z’ and the length is less than 10000.

Output

For each test case, output the encoded string in a line.

Sample Input

2

ABC

ABBCCC

Sample Output

ABC

A2B3C


题意:给你串字符串。让你统计并输出连续的字母,假设字母个数为1。则1忽略掉

#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std; int main()
{
int n;
scanf("%d", &n);
getchar();
while(n--){
char str[10010];
scanf("%s", str);
int len = strlen(str);
int count = 1;
for(int i = 0; i < len; i++){
if(str[i] == str[i+1])
count++;
else{
if(count == 1)
printf("%c", str[i]);
else{
printf("%d%c", count, str[i]);
count = 1;
}
}
}
printf("\n");
}
return 0;
}

B. Easier Done Than Said?

Problem Description

Password security is a tricky thing. Users prefer simple passwords that are easy to remember (like buddy), but such passwords are often insecure. Some sites use random computer-generated passwords (like xvtpzyo), but users have a hard time remembering them and sometimes leave them written on notes stuck to their computer. One potential solution is to generate “pronounceable” passwords that are relatively secure but still easy to remember.

FnordCom is developing such a password generator. You work in the quality control department, and it’s your job to test the generator and make sure that the passwords are acceptable. To be acceptable, a password must satisfy these three rules:

It must contain at least one vowel.

It cannot contain three consecutive vowels or three consecutive consonants.

It cannot contain two consecutive occurrences of the same letter, except for ‘ee’ or ‘oo’.

(For the purposes of this problem, the vowels are ‘a’, ‘e’, ‘i’, ‘o’, and ‘u’; all other letters are consonants.) Note that these rules are not perfect; there are many common/pronounceable words that are not acceptable.

Input

The input consists of one or more potential passwords, one per line, followed by a line containing only the word ‘end’ that signals the end of the file. Each password is at least one and at most twenty letters long and consists only of lowercase letters.

Output

For each password, output whether or not it is acceptable, using the precise format shown in the example.

Sample Input

a

tv

ptoui

bontres

zoggax

wiinq

eep

houctuh

end

Sample Output

is acceptable.

is not acceptable.

is not acceptable.

is not acceptable.

is not acceptable.

is not acceptable.

is acceptable.

is acceptable.


题意:题目中规定了password的形式例如以下:

1.password中必须有一个是元音字母

2.password中不能出现三个连续的元音字母或者三个连续的辅音字母

3.password中不能出现两个连续的同样的字母,除了”ee”和”oo”

给你一串password。让你推断这个password是否符合,输出按例子格式输出

#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std; int main()
{
char code[25];
while(scanf("%s", code)!=EOF){
if(!strcmp(code, "end"))
break;
int v, vv, cc, o, flag = 1; //v标记是否有元音字母,vv是连续元音字母的个数,cc连续辅音字母的个数。o是否有两个反复的字母
v = vv = cc = o = 0;
int len = strlen(code);
if(len == 1){ //仅仅有1个字母的情况单独推断
if(code[0]=='a' || code[0]=='e' || code[0]=='i' || code[0]=='o' || code[0]=='u')
flag = 1;
}
else{
for(int i = 0; i < len; i++){
if(code[i]=='a' || code[i]=='e' || code[i]=='i' || code[i]=='o' || code[i]=='u'){
v = 1;
vv++;
cc = 0;
}
else{
vv = 0;
cc++;
}
if(code[i] == code[i+1] && code[i]!='e' && code[i]!='o')
o = 1;
if(cc==3 || vv==3 || o==1){ //推断是否违反那几条规则
flag = 0;
break;
}
}
if(!v) flag = 0; //推断是否含有元音字母
}
if(flag)
printf("<%s> is acceptable.\n", code);
else
printf("<%s> is not acceptable.\n", code);
}
return 0;
}

D. A + B Problem II

Problem Description

I have a very simple problem for you. Given two integers A and B, your job is to calculate the Sum of A + B.

Input

The first line of the input contains an integer T(1<=T<=20) which means the number of test cases. Then T lines follow, each line consists of two positive integers, A and B. Notice that the integers are very large, that means you should not process them by using 32-bit integer. You may assume the length of each integer will not exceed 1000.

Output

For each test case, you should output two lines. The first line is “Case #:”, # means the number of the test case. The second line is the an equation “A + B = Sum”, Sum means the result of A + B. Note there are some spaces int the equation. Output a blank line between two test cases.

Sample Input

2

1 2

112233445566778899 998877665544332211

Sample Output

Case 1:

1 + 2 = 3

Case 2:

112233445566778899 + 998877665544332211 = 1111111111111111110


题意:大数相加,用数组处理

#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std; int main()
{
char str1[1010], str2[1010];
int a[1010], b[1010], c[1010];
int count = 1, n;
scanf("%d", &n);
getchar();
while(n--){
memset(a, 0, sizeof(a));
memset(b, 0, sizeof(b));
memset(c, 0, sizeof(c)); char str1[1010], str2[1010];
scanf("%s %s", str1, str2);
int len1 = strlen(str1);
int len2 = strlen(str2); for(int i = 0; i < len1; i++)
a[i] = str1[len1-i-1]-'0';
for(int i = 0; i < len2; i++)
b[i] = str2[len2-i-1]-'0'; int m = len1 > len2? len1:len2;
int up = 0;
for(int i = 0; i < m; i++){ //大数相加的核心
c[i] = a[i]+b[i]+up;
up = c[i]/10;
c[i]%=10;
} printf("Case %d:\n", count++);
printf("%s + %s = ", str1, str2);
int i = 0;
for(i = 1001; c[i]==0; i--);
for( ; i >= 0; i--)
printf("%d", c[i]);
printf("\n");
if(n) printf("\n");
}
return 0;
}

E. 素数判定

Problem Description

对于表达式n^2+n+41。当n在(x,y)范围内取整数值时(包括x,y)(-39<=x

Input

输入数据有多组,每组占一行,由两个整数x。y组成。当x=0,y=0时,表示输入结束。该行不做处理。

Output

对于每一个给定范围内的取值。假设表达式的值都为素数,则输出”OK”,否则请输出“Sorry”,每组输出占一行。

Sample Input

0 1

0 0

Sample Output

OK


#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
int mark[2800]; void prime(){ //先用筛选法把数素都标记好
memset(mark, 1, sizeof(mark));
mark[0] = mark[1] = 0;
int n = sqrt(2800);
for(int i = 2; i <= n; i++){
if(mark[i]){
for(int j = i*i; j < 2800; j+=i)
mark[j] = 0;
}
}
} int main()
{
int x, y;
prime();
while(scanf("%d %d", &x, &y)!=EOF){
if(!x && !y)
break;
int flag = 1;
for(int i = x; i <= y; i++){
if(mark[i*i+i+41])
continue;
else{
flag = 0;
break;
}
}
if(flag) printf("OK\n");
else printf("Sorry\n");
}
return 0;
}

F. 蟠桃记

Problem Description

喜欢西游记的同学肯定都知道悟空偷吃蟠桃的故事,你们一定都认为这猴子太闹腾了,事实上你们是有所不知:悟空是在研究一个数学问题!

什么问题?他研究的问题是蟠桃一共同拥有多少个!

只是。到最后,他还是没能解决这个难题,呵呵^-^

当时的情况是这种:

第一天悟空吃掉桃子总数一半多一个,第二天又将剩下的桃子吃掉一半多一个,以后每天吃掉前一天剩下的一半多一个,到第n天准备吃的时候仅仅剩下一个桃子。

聪明的你,请帮悟空算一下,他第一天開始吃的时候桃子一共同拥有多少个呢?

Input

输入数据有多组,每组占一行,包括一个正整数n(1

Output

对于每组输入数据,输出第一天開始吃的时候桃子的总数。每一个測试实例占一行。

Sample Input

2

4

Sample Output

4

22


数学问题

#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std; int main()
{
int n;
while(scanf("%d", &n)!=EOF){
int sum = 1;
for(int i = 2; i <= n; i++ ){
sum = sum*2+2;
}
printf("%d\n", sum);
}
return 0;
}

G. 大菲波数

Problem Description

Fibonacci数列,定义例如以下:

f(1)=f(2)=1

f(n)=f(n-1)+f(n-2) n>=3。

计算第n项Fibonacci数值。

Input

输入第一行为一个整数N。接下来N行为整数Pi(1<=Pi<=1000)。

Output

输出为N行。每行为相应的f(Pi)。

Sample Input

5

1

2

3

4

5

Sample Output

1

1

2

3

5


题意:还是大数相加,开个二维数组搞定

#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int fib[1010][220]; void fibo(){
for(int i = 0; i < 1010; i++)
for(int j = 0; j < 220; j++)
fib[i][j] = 0; fib[0][0] = fib[1][0] = 1;
for(int i = 2; i < 1000; i++){
int up, j;
up = j = 0;
while(j < 220){
fib[i][j] = fib[i-1][j] + fib[i-2][j] + up;
up = fib[i][j]/10;
fib[i][j]%=10;
j++;
}
}
} int main()
{
int n;
fibo();
scanf("%d", &n);
while(n--){
int m, i;
scanf("%d", &m); for(i = 219; fib[m-1][i] == 0; i--);
for(; i>=0; i--)
printf("%d", fib[m-1][i]);
printf("\n");
}
return 0;
}

ZZUACM 2015 暑假集训 round 01的更多相关文章

  1. 哈理工2015暑假集训 zoj 2975 Kinds of Fuwas

    G - Kinds of Fuwas Time Limit:2000MS    Memory Limit:65536KB    64bit IO Format:%lld & %llu Subm ...

  2. UCanCode发布升级E-Form++可视化源码组件库2015全新版 (V23.01)!

    2015年4月. 成都 UCanCode发布升级E-Form++可视化源码组件库2015全新版 (V23.01)! --- 全面性能提升,UCanCode有史以来最强大的版本发布! E-Form++可 ...

  3. 2015UESTC 暑假集训总结

    day1: 考微观经济学去了…… day2: 一开始就看了看一道题目最短的B题,拍了半小时交了上去wa了 感觉自己一定是自己想错了,于是去拍大家都过的A题,十分钟拍完交上去就A了 然后B题写了一发暴力 ...

  4. STL 入门 (17 暑假集训第一周)

    快速全排列的函数 头文件<algorithm> next_permutation(a,a+n) ---------------------------------------------- ...

  5. 暑假集训Day2 互不侵犯(状压dp)

    这又是个状压dp (大型自闭现场) 题目大意: 在N*N的棋盘里面放K个国王,使他们互不攻击,共有多少种摆放方案.国王能攻击到它上下左右,以及左上左下右上右下八个方向上附近的各一个格子,共8个格子. ...

  6. 暑假集训Day1 整数划分

    题目大意: 如何把一个正整数N(N长度<20)划分为M(M>=1)个部分,使这M个部分的乘积最大.N.M从键盘输入,输出最大值及一种划分方式. 输入格式: 第一行一个正整数T(T<= ...

  7. 2015暑假多校联合---CRB and His Birthday(01背包)

    题目链接 http://acm.split.hdu.edu.cn/showproblem.php?pid=5410 Problem Description Today is CRB's birthda ...

  8. 2015暑假多校联合---Zero Escape(变化的01背包)

    题目链接 http://acm.hust.edu.cn/vjudge/contest/130883#problem/C Problem Description Zero Escape, is a vi ...

  9. 暑假集训-WHUST 2015 Summer Contest #0.2

    ID Origin Title 10 / 55 Problem A Gym 100625A Administrative Difficulties   4 / 6 Problem B Gym 1006 ...

随机推荐

  1. 37.微信跳一跳辅助开发(C语言+EasyX)

    一.开发环境 开发环境 使用语言:C/C++ IDE:VS2010+ 其他三方库 EasyX(http://www.easyx.cn/downloads/) ADB(链接:https://pan.ba ...

  2. 利用Eventlog Analyzer分析日志

    利用EventlogAnalyzer分析日志 ManageEngineEventLogAnalyzer是一个基于Web技术.实时的事件监控管理解决方案,能够提高企业网络安全.减少工作站和服务器的宕机事 ...

  3. SQL 查找存在某内容的存储过程

    --查找存在某表名的存储过程 SELECT distinct b.name from syscomments a,sysobjects b WHERE a.id=b.id and a.TEXT LIK ...

  4. COWRUN

    USACO COWRUN 随机化搜索+双重递归调用 题面描述:给出8*N(<=14)组牌,每次按顺序选择8张,FJ可以选择前4张或者后4张,COW从FJ选出的牌中选择前两张或者后两张,然后COW ...

  5. 【Linux下禁用rm命令之建立回收站】

    第一步 创建回收站目录 # 根据自己的习惯,找个位置创建一个用作回收文件的目录 # 我们这里将在root目录下面创建一个名为".trash"的隐藏文件 [root@fedora ~ ...

  6. vim7.4官方源码在vs2013的编译方法及问题总结

    vim7.4发布也有一段时候了,也该是把之前编译的7.3重新编译一下了,于是考虑着到最新的visual studio 2013编译一下,也顺便看看有没有其它问题. 1.安装vs2013,这个应该不用说 ...

  7. 紫书 例题 9-7 UVa 11584 (线性结构上的动态规划)

    这道题判断回文串的方法非常的秀! 这里用到了记忆化搜索,因为会有很多重复 同时用kase来区分每一组数据 然后还有用递归来判断回文,很简洁 然后这种线性结构的动态规划的题,就是把 当前的这个数组分成两 ...

  8. qt hex to dec

    QString s = "32FE12AD";        quint8 u8vlaue = 0;        sscanf(s.toStdString().c_str(),  ...

  9. [Javascript] this in Function Calls

    In most cases, the value of a function's this argument is determined by how the function is called. ...

  10. opencv-图像金字塔

    图像金字塔 目标 原理摘自:http://www.opencv.org.cn/opencvdoc/2.3.2/html/doc/tutorials/imgproc/pyramids/pyramids. ...