辽宁省赛2010
来源:互联网 发布:单片机控制普通电机 编辑:程序博客网 时间:2024/05/01 19:42
- DinnerTime Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64uAppoint description:
Description
Little A is one member of ACM team. He had just won the gold in World Final. To celebrate, he decided to invite all to have one meal. As bowl, knife and other tableware is not enough in the kitchen, Little A goes to take backup tableware in warehouse. There are many boxes in warehouse, one box contains only one thing, and each box is marked by the name of things inside it. For example, if "basketball" is written on the box, which means the box contains only basketball. With these marks, Little A wants to find out the tableware easily. So, the problem for you is to help him, find out all the tableware from all boxes in the warehouse.Input
There are many test cases. Each case contains one line, and one integer N at the first, N indicates that there are N boxes in the warehouse. Then N strings follow, each string is one name written on the box.Output
For each test of the input, output all the name of tableware.Sample Input
3 basketball fork chopsticks2 bowl letter
Sample Output
fork chopsticksbowl
Hint
The tableware only contains: bowl, knife, fork and chopsticks.
- 输入中给的在加上题目中给的餐具,即为所有餐具,稍加判断就可以AC。
#include<stdio.h>#include<string.h>char s[10][20],ss[20];int main(){ int n; while(scanf("%d",&n)!=EOF) { int k=0; for(int i=0;i<n;i++) { scanf("%s",ss); if(strcmp(ss,"fork")==0||strcmp(ss,"chopsticks")==0||strcmp(ss,"bowl")==0||strcmp(ss,"knife")==0) //s[k]=ss; strcpy(s[k++],ss); } for(int i=0;i<k-1;i++) printf("%s ",s[i]); printf("%s\n",s[k-1]); } return 0;}
You are my brotherTime Limit:1000MS Memory Limit:131072KB 64bit IO Format:%I64d & %I64u最近Little A认识了一个新的朋友Little B,在他们聊天的时候他们竟然发现500年前他们是一家人,现在Little A想知道Little是他的长辈,晚辈,还是兄弟。所有的人都在一颗树上,只要知道A和B到根的距离,就可以判断他们的关系了。Appoint description:Description
Little A gets to know a new friend, Little B, recently. One day, they realize that they are family 500 years ago. Now, Little A wants to know whether Little B is his elder, younger or brother.
</br ></span style="line-height:normal;text-indent:27px;white-space:normal;font-family:'microsoft yahei';"></span style="line-height:normal;"></span style="font-family:'dejavu "></div style="text-indent:27px;">Input
There are multiple test cases.
For each test case, the first line has a single integer, n (n<=1000). The next n lines have two integers a and b (1<=a,b<=2000) each, indicating b is the father of a. One person has exactly one father, of course. Little A is numbered 1 and Little B is numbered 2.
Proceed to the end of file.Output
For each test case, if Little B is Little A’s younger, print “You are my younger”. Otherwise, if Little B is Little A’s elder, print “You are my elder”. Otherwise, print “You are my brother”. The output for each test case occupied exactly one line.Sample Input
51 32 43 54 65 661 32 43 54 65 76 7
Sample Output
You are my elderYou are my brother
#include<stdio.h>#define M 2007int pre[M],n;void init(){ for(int i=0;i<2007;i++) pre[i]=i;}int find(int x){ int count=0; while(x!=pre[x]) { x=pre[x]; count++; } return count;}int main(){ while(scanf("%d",&n)!=EOF) { init(); int a,b; while(n--) { scanf("%d%d",&a,&b); pre[a]=b; } int x=find(1); int y=find(2); if(x==y)printf("You are my brother\n"); else if(x>y)printf("You are my elder\n"); else if(x<y)printf("You are my younger\n"); } return 0;}
TimeTime Limit:1000MS Memory Limit:131072KB 64bit IO Format:%I64d & %I64uAppoint description:Description
Digital clock use 4 digits to express time, each digit is described by 3*3 characters (including”|”,”_”and” “).now given the current time, please tell us how can it be expressed by the digital clock.
</br ></span style="line-height:normal;text-indent:27px;white-space:normal;font-family:'microsoft yahei';"></span style="line-height:normal;"></span style="font-family:'dejavu "></div style="text-indent:27px;">Input
There are several test cases.
Each case contains 4 integers in a line, separated by space.
Proceed to the end of file.Output
For each test case, output the time expressed by the digital clock such as Sample Output.Sample Input
1 2 5 62 3 4 2
Sample Output
_ _ _ | _||_ |_ ||_ _||_| _ _ _ _| _||_| _||_ _| ||_
Hint
The digits showed by the digital clock are as follows: _ _ _ _ _ _ _ _ | _| _||_||_ |_ ||_||_|| | ||_ _| | _||_| ||_| _||_|
- 直接模拟所有情况。
#include<stdio.h>int s[4];int main(){ while(scanf("%d%d%d%d",&s[0],&s[1],&s[2],&s[3])!=EOF) { for(int i=1;i<=3;i++) { if(i==1) { for(int j=0;j<4;j++) { if(s[j]==2||s[j]==3||s[j]==5||s[j]==6||s[j]==7||s[j]==8||s[j]==9||s[j]==0) printf(" _ "); else printf(" "); } printf("\n"); } if(i==2) { for(int j=0;j<4;j++) { if(s[j]==1||s[j]==7) printf(" |"); else if(s[j]==2||s[j]==3) printf(" _|"); else if(s[j]==4||s[j]==8||s[j]==9) printf("|_|"); else if(s[j]==5||s[j]==6) printf("|_ "); else printf("| |"); } printf("\n"); } if(i==3) { for(int j=0;j<4;j++) { if(s[j]==1||s[j]==4||s[j]==7) printf(" |"); else if(s[j]==6||s[j]==8||s[j]==0) printf("|_|"); else if(s[j]==3||s[j]==5||s[j]==9) printf(" _|"); else if(s[j]==2) printf("|_ "); } printf("\n"); } } } return 0;}
SPYTime Limit:1000MS Memory Limit:131072KB 64bit IO Format:%I64d & %I64u从s2数组里面找s1存在的,去掉s3里面的。即为所求。Appoint description:Description
The National Intelligence Council of X Nation receives a piece of credible information that Nation Y will send spies to steal Nation X’s confidential paper. So the commander of The National Intelligence Council take measures immediately, he will investigate people who will come into NationX. At the same time, there are two List in the Commander’s hand, one is full of spies that Nation Y will send to Nation X, and the other one is full of spies that Nation X has sent to Nation Y before. There may be some overlaps of the two list. Because the spy may act two roles at the same time, which means that he may be the one that is sent from Nation X to Nation Y, we just call this type a “dual-spy”. So Nation Y may send “dual_spy” back to Nation X, and it is obvious now that it is good for Nation X, because “dual_spy” may bring back NationY’s confidential paper without worrying to be detention by NationY’s frontier So the commander decides to seize those that are sent by NationY, and let the ordinary people and the “dual_spy” in at the same time .So can you decide a list that should be caught by the Commander?
A:the list contains that will come to the NationX’s frontier.
B:the list contains spies that will be sent by Nation Y.
C:the list contains spies that were sent to NationY before.
Input
There are several test cases.
Each test case contains four parts, the first part contains 3 positive integers A, B, C, and A is the number which will come into the frontier. B is the number that will be sent by Nation Y, and C is the number that NationX has sent to NationY before.
The second part contains A strings, the name list of that will come into the frontier.
The second part contains B strings, the name list of that are sent by NationY.
The second part contains C strings, the name list of the “dual_spy”.
There will be a blank line after each test case.
There won’t be any repetitive names in a single list, if repetitive names appear in two lists, they mean the same people.Output
Output the list that the commander should caught (in the appearance order of the lists B).if no one should be caught, then , you should output “No enemy spy”.Sample Input
8 4 3Zhao Qian Sun Li Zhou Wu Zheng WangZhao Qian Sun LiZhao Zhou Zheng2 2 2Zhao QianZhao QianZhao Qian
Sample Output
Qian Sun LiNo enemy spy
#include<stdio.h>#include<string.h>char s1[1007][20],s2[1007][20],s3[1007][20],s[1007][20];bool vis[1007];int main(){ int a,b,c,flag; while(scanf("%d%d%d",&a,&b,&c)!=EOF) { memset(s1,0,sizeof(s1)); memset(s2,0,sizeof(s2)); memset(s3,0,sizeof(s3)); memset(s,0,sizeof(s)); memset(vis,0,sizeof(vis)); for(int i=0;i<a;i++) scanf("%s",s1[i]); for(int i=0;i<b;i++) { flag=0; scanf("%s",s2[i]); for(int j=0;j<a;j++) if(strcmp(s2[i],s1[j])==0){flag=1;break;} if(flag)vis[i]=1; } for(int i=0;i<c;i++) { scanf("%s",s3[i]); for(int j=0;j<b;j++) if(strcmp(s3[i],s2[j])==0&&vis[j]) { vis[j]=0; break; } } int k=0; for(int i=0;i<b;i++) if(vis[i]) { strcpy(s[k++],s2[i]); } if(!k)printf("No enemy spy\n"); else { for(int i=0;i<k-1;i++) printf("%s ",s[i]); printf("%s\n",s[k-1]); } } return 0;}
NEW RDSP MODE ITime Limit:1000MS Memory Limit:131072KB 64bit IO Format:%I64d & %I64uAppoint description:Description
Little A has became fascinated with the game Dota recently, but he is not a good player. In all the modes, the rdsp Mode is popular on online, in this mode, little A always loses games if he gets strange heroes, because, the heroes are distributed randomly.
Little A wants to win the game, so he cracks the code of the rdsp mode with his talent on programming. The following description is about the rdsp mode:
There are N heroes in the game, and they all have a unique number between 1 and N. At the beginning of game, all heroes will be sorted by the number in ascending order. So, all heroes form a sequence One.
These heroes will be operated by the following stages M times:
1.Get out the heroes in odd position of sequence One to form a new sequence Two;
2.Let the remaining heroes in even position to form a new sequence Three;
3.Add the sequence Two to the back of sequence Three to form a new sequence One.
After M times' operation, the X heroes in the front of new sequence One will be chosen to be Little A's heroes. The problem for you is to tell little A the numbers of his heroes.
Input
There are several test cases.
Each case contains three integers N (1<=N<1,000,000), M (1<=M<100,000,000), X(1<=X<=20).
Proceed to the end of file.Output
For each test case, output X integers indicate the number of heroes. There is a space between two numbers. The output of one test case occupied exactly one line.Sample Input
5 1 25 2 2
Sample Output
2 44 3
Hint
In case two: N=5,M=2,X=2,the initial sequence One is 1,2,3,4,5.After the first operation, the sequence Oneis 2,4,1,3,5. After the second operation, the sequence One is 4,3,2,1,5.So,output 4 3.
- 2*k 跟 2*k+1 数字的前2*k个字符变化完全相同,当为2*k+1数列,第2*k+1个数永远为2*k+1
- 第一个数字是 1*2^(m)%n ,第2个数字是2*2^(m)%n,第3个是3*2^(m)%n,以此类推。
- 计算2^n时。可采用乘法加速幂来进行快速运算。
#include<stdio.h>long long pow(long long a,long long n,long long mod)//返回a^n%mod{ long long r=1; while(n) { if(n&1)r=(a*r)%mod; a=(a*a)%mod; n>>=1; } return r;}int main(){ long long n,m,k,s,ans; while(scanf("%lld%lld%lld",&n,&m,&k)!=EOF) { if(!(n&1))n++;//n是偶数就++ s=pow(2,m,n); printf("%lld",s); ans=s; for(int i=1;i<k;i++) { ans+=s;ans%=n; printf(" %lld",ans); } printf("\n"); } return 0;}
Friends numberTime Limit:1000MS Memory Limit:131072KB 64bit IO Format:%I64d & %I64uAppoint description:Description
Paula and Tai are couple. There are many stories between them. The day Paula left by airplane, Tai send one message to telephone 2200284, then, everything is changing… (The story in “the snow queen”).
After a long time, Tai tells Paula, the number 220 and 284 is a couple of friends number, as they are special, all divisors of 220’s sum is 284, and all divisors of 284’s sum is 220. Can you find out there are how many couples of friends number less than 10,000. Then, how about 100,000, 200,000 and so on.
The task for you is to find out there are how many couples of friends number in given closed interval [a,b]。
Input
There are several cases.
Each test case contains two positive integers a, b(1<= a <= b <=5,000,000).
Proceed to the end of file.Output
For each test case, output the number of couples in the given range. The output of one test case occupied exactly one line.Sample Input
1 1001 1000
Sample Output
01
Hint
6 is a number whose sum of all divisors is 6. 6 is not a friend number, these number is called Perfect Number.
- 竟然是打表,真是想不到,还以为是算数基本定理了。。。。
#include <stdio.h>int ans[56][2]={ 220,284, 284,220, 1184,1210, 1210,1184, 2620,2924, 2924,2620, 5020,5564, 5564,5020, 6232,6368, 6368,6232, 10744,10856, 10856,10744, 12285,14595, 14595,12285, 17296,18416, 18416,17296, 63020,76084, 66928,66992, 66992,66928, 67095,71145, 69615,87633, 71145,67095, 76084,63020, 79750,88730, 87633,69615, 88730,79750, 100485,124155, 122265,139815, 122368,123152, 123152,122368, 124155,100485, 139815,122265, 141664,153176, 142310,168730, 153176,141664, 168730,142310, 171856,176336, 176272,180848, 176336,171856, 180848,176272, 185368,203432, 196724,202444, 202444,196724, 203432,185368, 280540,365084, 308620,389924, 319550,430402, 356408,399592, 365084,280540, 389924,308620, 399592,356408, 430402,319550, 437456,455344, 455344,437456, 469028,486178, 486178,469028};int main(){ int a,b,i; while(scanf("%d %d",&a,&b)!=EOF) { int count=0; for(int i=0; i<56; i++) if(a<=ans[i][0]&&ans[i][0]<ans[i][1]&&ans[i][1]<=b) count++; printf("%d\n",count); } return 0;}
- 辽宁省赛2010
- 辽宁省赛2010
- 辽宁省赛2010 G
- 2010 辽宁省省赛 题解
- Friends number 2010辽宁省赛
- 2010 ACM/ICPC 辽宁省赛 Dinner
- 【9018p1316】SPY(辽宁省赛2010)
- 辽宁省赛2010 G题 Friends Number
- 辽宁省赛2010-time[水题]
- 2010辽宁省赛You are my brother
- 2014辽宁省赛 Traveling
- 辽宁省赛总结
- 2010辽宁省赛 NBUT 1222 English Game【字典树+DP】
- 2012.6辽宁省赛 Problem F
- 2014辽宁省赛 Repeat Number
- 2014年辽宁省赛 distance
- 忆2015年辽宁省赛
- 2010年辽宁省赛 NBUT 1218【DFS实现树的遍历与更新】
- Linux内核的安装
- 算法学习(二)快速排序(上)
- UIButton
- 进入黑马的第一天学习--HTML
- flappy bird游戏源代码揭秘和下载后续---移植到android真机上
- 辽宁省赛2010
- HDU1033 Edge
- 【WampServer + DedeCMS-V5.7】下本地建站流程
- JVM内存溢出的方式
- C++从菜鸟做起——文件的写入方法
- LeetCode 018 4Sum
- load 文件系统满报错
- <<Windows核心编程(第五版)>>第15~18章内存管理
- POJ 1017 Packets