大学生程序设计邀请赛(华东师范大学)
来源:互联网 发布:土布鱼女装淘宝 编辑:程序博客网 时间:2024/04/29 03:21
网址:http://acm.ecnu.edu.cn/contest/11/
A. 拼音魔法
Time limit per test: 1.0 seconds
Time limit all tests: 1.0 seconds
Memory limit: 256 megabytes
Accept / Submit: 341 / 2134
魔法学校小学一年级有一种题。就是给一个字的拼音,给一个声调,让你正确地注音。但魔法老师给了巨量的题,你不用魔法根本不可能做完。所以现在要让你发明一种魔法完成这个任务。
问题已经讲完了,下面开始教授汉语。(会汉语或者自认为会汉语的可以自动跳过)
汉语中一个字的拼音由声母和韵母两部分组成,在极少数情况下也会没有声母,但一定有韵母。
一般认为,声母有 b, p, m, f, d, t, l, n, g, k, h, j, q, x, z, c, s, zh, ch, sh, r, y, w;韵母有:a, e, o, i, u, ü, ai, ei, ui, ao, ou, iu, ie, üe, er, an, en, in, un, ün, ang, eng, ing, ong。
不是所有的字母都能组合的,组合的时候有时会发生一些神奇的事情,例如 üe 变成了 ue。但是标调规则有如下口诀:
有 a 先找 a,没 a 找 o e,i u 并排标在后,这样标调不会错。
只有下面列出的元素可能会被标调。请按照下表输出(尤其注意 a 不要输出成 ɑ 了):
第一声:ā ē ī ō ū ǖ。
第二声:á é í ó ú ǘ。
第三声:ǎ ě ǐ ǒ ǔ ǚ。
第四声:à è ì ò ù ǜ。
轻声:a e i o u ü。
辅助材料:由教育部公布的拼音方案。如果有描述不一致的地方,请以本题描述为准。
Input
第一行一个整数 T (1≤T≤105)。
下面 T 行,每行一个拼音:拼音声调在各个拼音之后,用数字 [1-4] 进行表示。例如 zhong1 guo2。没有数字的说明是轻声,不用标调。
按照国际惯例,输入文件全部由 ASCII 编码组成。ü 用 v 来代替。但在输出中,应仍然用 ü 来表示。
Output
对于每一组数据,输出 Case x: y。其中 x 是从 1 开始的测试数据编号,y 是一个拼音标调后的答案。
注意:对于非 ASCII 字符的输出,请使用 UTF-8 编码。
Examples
input
5
zhong1
guo2
me
que1
nv3
output
Case 1: zhōng
Case 2: guó
Case 3: me
Case 4: quē
Case 5: nǚ
题目说的 UTF-8 编码 我也不知道是什么,反正char是弄不出来的,就弄个string就行了。
然后就是各种if、else就写完了,打表要注意不要多打了,刚开始多打了个空格,找错找了半天。
还要注意v可能是ǚ也可能是u这样的,具体怎么变看题目说明。
#include<iostream>#include<stdio.h>#include<string.h>#include<queue>#include<map>using namespace std;int main(){ int T; cin>>T; string mp[333][10]; mp['a'][0]="a";mp['e'][0]="e";mp['i'][0]="i";mp['o'][0]="o";mp['u'][0] ="u" ;mp['v'][0]="ü"; mp['a'][1]="ā";mp['e'][1]="ē";mp['i'][1]="ī";mp['o'][1]="ō";mp['u'][1] ="ū" ;mp['v'][1]="ǖ"; mp['a'][2]="á";mp['e'][2]="é";mp['i'][2]="í";mp['o'][2]="ó";mp['u'][2] ="ú" ;mp['v'][2]="ǘ"; mp['a'][3]="ǎ";mp['e'][3]="ě";mp['i'][3]="ǐ";mp['o'][3]="ǒ";mp['u'][3] ="ǔ" ;mp['v'][3]="ǚ"; mp['a'][4]="à";mp['e'][4]="è";mp['i'][4]="ì";mp['o'][4]="ò";mp['u'][4] ="ù" ;mp['v'][4]="ǜ"; for(int cas=1;cas<=T;cas++) { char str[100]; cin>>str; int f=0,num=0; if(str[strlen(str)-1]>='1'&&str[strlen(str)-1]<='4') f=1,num=str[strlen(str)-1]-'0'; cout<<"Case "<<cas<<": "; if(f) str[strlen(str)-1]=0; int a=-1,e=-1,ii=-1,o=-1,u=-1,v=-1; for(int i=0;i<strlen(str);i++) { if(str[i]=='a') a=i; else if(str[i]=='e') e=i; else if(str[i]=='i') ii=i; else if(str[i]=='o') o=i; else if(str[i]=='u') u=i; else if(str[i]=='v') v=i; } if(a!=-1) { for(int i=0;i<strlen(str);i++) { if(i==a) cout<<mp['a'][num]; else { if(str[i]=='v') cout<<"ü"; else cout<<str[i]; } } cout<<endl; continue; } if(e!=-1) { for(int i=0;i<strlen(str);i++) { if(i==e) cout<<mp['e'][num]; else { if(str[i]=='v') cout<<'u'; else cout<<str[i]; } } cout<<endl; continue; } if(o!=-1) { for(int i=0;i<strlen(str);i++) { if(i==o) cout<<mp['o'][num]; else cout<<str[i]; } cout<<endl; continue; } if(ii!=-1) { if(u==-1) { for(int i=0;i<strlen(str);i++) { if(i==ii) cout<<mp['i'][num]; else cout<<str[i]; } cout<<endl; continue; } else { if(ii>u) { for(int i=0;i<strlen(str);i++) { if(i==ii) cout<<mp['i'][num]; else cout<<str[i]; } cout<<endl; continue; } else { for(int i=0;i<strlen(str);i++) { if(i==u) cout<<mp['u'][num]; else cout<<str[i]; } cout<<endl; continue; } } } if(u!=-1) { for(int i=0;i<strlen(str);i++) { if(i==u) cout<<mp['u'][num]; else cout<<str[i]; } cout<<endl; continue; } if(v!=-1) { int flag=0; for(int i=0;i<strlen(str);i++) { if(str[i]=='n'||str[i]=='l') flag = 1; if(i==v) { if(flag==0) cout<<mp['u'][num]; else cout<<mp['v'][num]; } else cout<<str[i]; } cout<<endl; continue; } } return 0;}
C. 袋鼠妈妈找孩子
Time limit per test: 1.5 seconds
Time limit all tests: 10.0 seconds
Memory limit: 256 megabytes
Accept / Submit: 41 / 172
袋鼠妈妈找不到她的孩子了。她的孩子被怪兽抓走了。
袋鼠妈妈现在在地图的左上角,她的孩子在地图第 x 行第 y 列的位置。怪兽想和袋鼠妈妈玩一个游戏:他不想让袋鼠妈妈过快地找到她的孩子。袋鼠妈妈每秒钟可以向上下左右四个方向跳一格(如果没有墙阻拦的话),怪兽就要在一些格子中造墙,从而完成一个迷宫,使得袋鼠妈妈能够找到她的孩子,但最快不能小于 k 秒。
请设计这样一个迷宫。
Input
第一行两个整数 n,m (1≤n,m≤8),表示地图的总行数和总列数。
第二行三个整数 x,y,k (1≤x≤n,1≤y≤m,x+y>1)。
Output
输出一个地图,应正好 n 行 m 列。
用 . 表示空地,用 * 表示墙。袋鼠妈妈所在的位置和孩子所在的位置用 . 表示。
数据保证有解。
Examples
input
2 6
1 3 4
output
.*.***
……
暴力搜索(DFS)
#include<iostream>#include<stdio.h>#include<string.h>using namespace std;char map[10][10];int n,m,ex,ey,k;int vis[10][10];int dir[4][2]={{0,1},{1,0},{0,-1},{-1,0}};int flag;void dfs(int h,int l,int step){ if(h==ex&&l==ey) { if(step<k) return; flag=1; return ; } for(int i=0;i<4;i++) { int hh = h + dir[i][0]; int ll = l + dir[i][1]; if(hh<1||hh>n||ll<1||ll>m||vis[hh][ll]==1) continue; int j; for(j=0;j<4;j++) { if(vis[hh+dir[j][0]][ll+dir[j][1]]==1)//有其他更近的点可以到达这一点那就不能走 break; } if(j<4) continue; map[h][l]='.'; vis[h][l] = 1; dfs(hh,ll,step+1); if(flag) return; map[h][l]='*'; vis[h][l] = 0; }}int main(){ while(~scanf("%d%d",&n,&m)) { scanf("%d%d%d",&ex,&ey,&k); for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) map[i][j]='*'; memset(vis,0,sizeof vis); flag = 0; dfs(1,1,0); map[ex][ey]='.'; for(int i=1;i<=n;i++) { for(int j=1;j<=m;j++) { printf("%c",map[i][j]); } printf("\n"); } } return 0;}
E. 黑心啤酒厂
Time limit per test: 1.0 seconds
Time limit all tests: 1.0 seconds
Memory limit: 256 megabytes
Accept / Submit: 1184 / 4093
黑心啤酒厂为了让大家买啤酒,会把一瓶酒设计成恰好能倒七杯。由于聚会时经常会有大家一起干杯这样的事情,干杯之前又要给每个人都倒满,所以来两个人的时候,干完三轮,恰好多一杯;三个人的时候,干完两轮,恰好多一杯;四个人的时候会多三杯。在上述情况下,为了践行不浪费的原则,就会多买一瓶啤酒,再干一轮。当然多买的啤酒可能又有多了……然后循环往复,喝了好多好多。直到啤酒刚刚好喝完为止。
现在啤酒厂把酒瓶设计成刚好能倒 x 杯,请依次求出有 2 人、3 人,一直到 n 人参加聚会时,啤酒厂各能卖出多少瓶啤酒。
Input
输入只有一行,两个整数 x,n (1≤x≤109,2≤n≤105)。
Output
输出 n−1 行,分别表示 2,3,…,n 人参加聚会时,能卖出的啤酒瓶数。
Examples
input
7 5
output
2
3
4
5
m * x % n = = 0
m * x = lcm( x , n );
lcm( x , n ) = x * n / gcd( x , n )
m = n / gcd( x , n )
m即为最少卖出瓶数
#include<iostream>#include<stdio.h>using namespace std;long gcd (long a,long b){ while(a>0) { long c = b % a; b = a ; a = c ; } return b ;}int main(){ long n,x; scanf("%ld%ld",&x,&n); for(int i=2;i<=n;i++) { cout<<x*i/gcd(x,i)/x<<endl; } return 0;}
- 大学生程序设计邀请赛(华东师范大学)
- 大学生程序设计邀请赛(华东师范大学)
- 大学生程序设计邀请赛(华东师范大学)
- 大学生程序设计邀请赛(华东师范大学)
- 大学生程序设计邀请赛(华东师范大学) 黑心啤酒厂
- 大学生程序设计邀请赛(华东师范大学网赛)
- 大学生程序设计邀请赛(华东师范大学)-F-贪心
- 大学生程序设计邀请赛(华东师范大学)A
- 大学生程序设计邀请赛(华东师范大学)题解
- 大学生程序设计邀请赛(华东师范大学)A. 拼音魔法
- EOJ-大学生程序设计邀请赛(华东师范大学)-A-拼音魔法
- EOJ-大学生程序设计邀请赛(华东师范大学)-E-黑心啤酒厂
- 大学生程序设计邀请赛(华东师范大学)C:袋鼠妈妈找孩子
- A. 拼音魔法 大学生程序设计邀请赛(华东师范大学)
- EOJ-大学生程序设计邀请赛(华东师范大学)-G-铁路修复计划
- EOJ-大学生程序设计邀请赛(华东师范大学)-A-拼音魔法
- EOJ-大学生程序设计邀请赛(华东师范大学)-E-黑心啤酒厂
- EOJ-大学生程序设计邀请赛(华东师范大学)-B-分词
- 特征工程(1)--特征工程是什么?
- RecyclerView分割线-ItemDecoration
- js禁止方法频繁执行
- HTML实现仿百度图片触发后跳出相关文字机制
- 结巴中文分词安装与使用
- 大学生程序设计邀请赛(华东师范大学)
- mac系统使用homebrew 无法安装nodejs解决方案
- 二叉树面试题汇总
- React小白进门
- python的学习知识点总结
- 反射调用属性成员
- 3步告别忙累压力大没成绩
- c语言中函数调用的原理
- Log4j使用教程