几组n个学生玩游戏花屏退出数到3退出 c语言

"c语言输入n组数据"的糗事
你可能感兴趣:
糗事百科为大家收集了很多的c语言输入n组数据的糗事,各种关于c语言输入n组数据的爆笑经历、尴尬时刻和开心视频,想持续关注c语言输入n组数据的糗事就收藏本页吧.
扫码下载糗事百科app距离输出0输入第一行给出测试数据组数N
时间: 23:14:46
【南阳OJ分类之语言入门】80题题目+AC代码汇总小技巧:本文之前由csdn自动生成了一个目录,不必下拉一个一个去找,可通过目录标题直接定位。&&&&本文转载自本人的csdn博客,复制过来的,排版就不弄了,欢迎转载。&&&&声明:&&&&&& & & 题目部分皆为南阳OJ题目。&&&&& & 代码部分包含AC代码(可能不止一个)和最优代码,大部分都是本人写的,并且大部分为c代码和少部分c++代码and极少java代码,但基本都是c语言知识点,没有太多差别,可能代码有的写的比较丑,毕竟知识有限。&&&&& &语言入门部分题基本都较为简单,是学习编程入门的很好练习,也是ACM的第一步,入门的最佳方法,望认真对待。&&&&&& &本文由csdn-jtahstu原创,转载请注明出处,欢迎志同道合的朋友一起交流学习。本人QQ:和csdn博客地址,链接:http://blog.csdn.net/jtahstu&&&&&& 该分类南阳OJ地址:我是地址,链接:http://acm./JudgeOnline/problemset.php?typeid=1&&&&Now&begin&&&&1、&&&&&&&&&A+B Problem&&&&时间限制:&&&&难度:0&&&&描述 此题为练手用题,请大家计算一下a+b的值输入输入两个数,a,b输出输出a+b的值样例输入&&&&2 3&&&&样例输出&&&&5&&&&提示例如:C语言版:&&&&#include&stdio.h&&&&&int main()&&&&{&&&&int a,b;&&&&scanf("%d%d",&a,&b);&&&&printf("%d\n",a+b);&&&&} &&&&C++版:&&&&#include&iostream&&&&&&&&&int main()&&&&{&&&&int a,b;&&&&cin&&a&&b;&&&&cout&&a+b&&&&&&}&&&&&&&&Java版:&&&&import java.io.*;&&&&import java.util.*;&&&&public class Main&&&&{&&&&public static void main(String args[]) throws Exception&&&&{&&&&Scanner cin=new Scanner(System.in);&&&&int a=cin.nextInt(),b=cin.nextInt();&&&&System.out.println(a+b);&&&&}&&&&}&&&&&&&&Java jdk 1.4 版&&&&import java.io.*;&&&&import java.util.*;&&&&public class Main&&&&{&&&&public static void main (String args[]) throws Exception&&&&{&&&&BufferedReader stdin =&&&&new BufferedReader(&&&&new InputStreamReader(System.in));&&&&String line = stdin.readLine();&&&&StringTokenizer st = new StringTokenizer(line);&&&&int a = Integer.parseInt(st.nextToken());&&&&int b = Integer.parseInt(st.nextToken());&&&&System.out.println(a+b);&&&&}&&&&}&&&&请注意不要输出过多提示性语句(如:&please input two numbers&),不然会WrongAnswer的&&&& &&&&#include&stdio.h&&&&&int main()&&&&{&&&&
int a,b;&&&&
scanf("%d%d",&a,&b);&&&&
printf("%d\n",a+b);&&&&} &&&&&&&&&#include&iostream&&&&&main(){std::cout&&(1&&31)-1;}&&&&&&& &&&&
&&&&4、&&&&ASCII码排序&&&&时间限制:&&&&难度:2&&&&描述输入三个字符(可以重复)后,按各字符的ASCII码从小到大的顺序输出这三个字符。输入第一行输入一个数N,表示有N组测试数据。后面的N行输入多组数据,每组输入数据都是占一行,有三个字符组成,之间无空格。输出对于每组输入数据,输出一行,字符中间用一个空格分开。样例输入&&&&2&&&&qwe&&&&asd&&&&样例输出&&&&e q w&&&&a d s&&&&来源网络上传者naonao&&&&#include&stdio.h&&&&&#define MAX 3&&&&char a[MAX];&&&&int main() {&&&& &&&& scanf("%d\n", &n);&&&& while (n--) {&&&&
char x, y,&&&&
scanf("%s", a);&&&&
x = a[0];&&&&
if (a[1] & x)&&&&
x = a[1];&&&&
if (a[2] & x)&&&&
x = a[2];&&&&
z = a[2];&&&&
if (a[1] & z)&&&&
z = a[1];&&&&
if (a[0] & z)&&&&
z = a[0];&&&&
y = a[0] + a[1] + a[2] - x -&&&&
printf("%c %c %c\n", x, y, z);&&&& }&&&& return 0;&&&&}&&&&#include "stdio.h"//最优程序&&&&main()&&&&{&&&& char a,b,c,d;&&&& &&&& scanf("%d",&i);&&&& getchar();&&&& while(i--)&&&& {&&&&
scanf("%c%c%c",&a,&b,&c);&&&&
getchar();&&&&
if (a&b) {d=a;a=b;b=d;}&&&&
if (a&c) {d=a;a=c;c=d;}&&&&
if (b&c) {d=b;b=c;c=d;}&&&&
printf("%c %c %c\n",a,b,c);&&&& }&&&&}&&&&&&&&11、&&&&奇偶数分离&&&&时间限制:&&&&难度:1&&&&描述 有一个整型偶数n(2&= n &=10000),你要做的是:先把1到n中的所有奇数从小到大输出,再把所有的偶数从小到大输出。输入第一行有一个整数i(2&=i&30)表示有 i 组测试数据;每组有一个整型偶数n。输出第一行输出所有的奇数第二行输出所有的偶数样例输入&&&&2&&&&10&&&&14&&&&样例输出&&&&1 3 5 7 9 &&&&2 4 6 8 10 &&&&1 3 5 7 9 11 13 &&&&2 4 6 8 10 12 14 &&&&&&&&来源[苗栋栋]原创上传者苗栋栋&&&&# include"stdio.h"&&&&int main() {&&&& int i, b, c, d, j,&&&& scanf("%d", &i);&&&& for (d = 0; d & d++) {&&&&
scanf("%d", &b);&&&&
for (k = 1; k &= k++) {&&&&
if ((k % 2) == 1)&&&&
printf("%d ", k);&&&&
printf("\n");&&&&
for (j = 1; j &= j++) {&&&&
if ((j % 2) == 0)&&&&
printf("%d ", j);&&&&
printf("\n");&&&& }&&&& return 0;&&&&}&&&&#include&stdio.h&//最优程序&&&&int main() {&&&& &&&& scanf("%d", &n);&&&& &&&& while (n--) {&&&&
scanf("%d", &a);&&&&
for (int i = 1; i &= i += 2)&&&&
printf("%d ", i);&&&&
puts("");&&&&
for (int i = 2; i &= i += 2)&&&&
printf("%d ", i);&&&&
puts("");&&&& }&&&&}&&&&13、&&&&Fibonacci数&&&&时间限制:&&&&难度:1&&&&描述 无穷数列1,1,2,3,5,8,13,21,34,55...称为Fibonacci数列,它可以递归地定义为F(n)=1 ...........(n=1或n=2)F(n)=F(n-1)+F(n-2).....(n&2)现要你来求第n个斐波纳奇数。(第1个、第二个都为1)输入第一行是一个整数m(m&5)表示共有m组测试数据每次测试数据只有一行,且只有一个整形数n(n&20)输出对每组输入n,输出第n个Fibonacci数样例输入&&&&3&&&&1&&&&3&&&&5&&&&样例输出&&&&1&&&&2&&&&5&&&&来源经典题目上传者张云聪&&&&#include &stdio.h&&&&&int F(int n) {&&&& if (n == 1 || n == 2) {&&&&
return 1;&&&& } else {&&&&
return F(n - 1) + F(n - 2);&&&& }&&&&}&&&&int main() {&&&& int i,&&&& scanf("%d", &i);&&&& while (i--) {&&&&
scanf("%d", &n);&&&&
printf("%d\n", F(n));&&&& }&&&& return 0;&&&&}&&&&#include&stdio.h&//最优程序&&&&main()&&&&{&&&& int m,n,i,s1,s2;&&&& scanf("%d",&m);&&&& while(m--)&&&& { scanf("%d",&n);&&&&
for(i=3,s1=s2=1;i&=n;i++)&&&&
s1=s1+s2;s2=s1-s2;&&&&
printf("%d\n",s1);&&&& }&&&&}&&&&22、&&&&素数求和问题&&&&时间限制:&&&&难度:2&&&&描述 现在给你N个数(0&N&1000),现在要求你写出一个程序,找出这N个数中的所有素数,并求和。输入第一行给出整数M(0&M&10)代表多少组测试数据每组测试数据第一行给你N,代表该组测试数据的数量。接下来的N个数为要测试的数据,每个数小于1000输出每组测试数据结果占一行,输出给出的测试数据的所有素数和样例输入&&&&3&&&&5&&&&1 2 3 4 5&&&&8&&&&11 12 13 14 15 16 17 18&&&&10&&&&21 22 23 24 25 26 27 28 29 30&&&&&&&&样例输出&&&&10&&&&41&&&&52&&&&&&&&来源[hzyqazasdf]原创上传者hzyqazasdf&&&&#include&stdio.h&&&&&#include&math.h&&&&&int main() {&&&& int i, j, k, a, n, m, sum = 0;&&&& scanf("%d", &a);&&&& for (i = 0; i & i++) {&&&&
scanf("%d", &n);&&&&
for (j = 0; j & j++) {&&&&
scanf("%d", &m);&&&&
for (k = 2; k &= sqrt(m); k++) {&&&&
if (m % k == 0)&&&&
if (k & sqrt(m) && m != 1)&&&&
sum = sum +&&&&
printf("%d\n", sum);&&&&
sum = 0;&&&& }&&&& return 0;&&&&}&&&&#include&stdio.h&//最优程序&&&&#include &math.h&&&&&int main()&&&&{&&&& int m,n,i,j,a[1000],flag=0;&&&& &&&& scanf("%d",&m);&&&& while(m--)&&&& {&&&&
scanf("%d",&n);&&&&
for(i=0;i&n;i++)&&&&
scanf("%d",&a[i]);&&&&
for(i=0;i&n;i++)&&&&
if(a[i]==1) &&&&
flag=0;&&&&
for(j=2;j&=sqrt(a[i]);j++)&&&&
if(a[i]%j==0)&&&&
if(flag==0) s+=a[i];&&&&
}&&&& printf("%d\n",s);&&&& }&&&& return 0;&&&&}
&&&&24、&&&&素数距离问题&&&&时间限制:&&&&难度:2&&&&描述 现在给出你一些数,要求你写出一个程序,输出这些整数相邻最近的素数,并输出其相距长度。如果左右有等距离长度素数,则输出左侧的值及相应距离。如果输入的整数本身就是素数,则输出该素数本身,距离输出0输入第一行给出测试数据组数N(0&N&=10000)接下来的N行每行有一个整数M(0&M&1000000),输出每行输出两个整数 A B.其中A表示离相应测试数据最近的素数,B表示其间的距离。样例输入&&&&3&&&&6&&&&8&&&&10&&&&样例输出&&&&5 1&&&&7 1&&&&11 1&&&&来源经典题目上传者hzyqazasdf&&&& &&&&#include&stdio.h&&&&&#include&math.h&&&&&bool judge(int m);&&&&int main()&&&&{&&&&
int N,n,i;&&&&
scanf("%d",&N);&&&&
while(N--)&&&&
scanf("%d",&n);&&&&
if(judge(n))&&&&
printf("%d 0\n",n);&&&&&&&&
for(i=1; n-i!=-1; i++)&&&&
if(judge(n-i))&&&&
printf("%d %d\n",n-i,i);&&&& &&&&
if(judge(n+i))&&&&
printf("%d %d\n",n+i,i);&&&& &&&&
return 0;&&&&}&&&&bool judge(int m)&&&&{&&&&
if(m==0||m==1)&&&&&&&&&&&&
for(i=2; i&=sqrt(m); i++)&&&&
if(m%i==0)&&&&
if(i&sqrt(m))&&&&&&&&&&&&}&&&& &&&&#include&iostream&//最优程序&&&&#include&cmath&&&&&&&&&bool isprime(int n)&&&&{&&&& for(int k=2;k&=sqrt((double)n);k++)&&&&
if((n%k)==0)&&&&
&&&& &&&&}&&&&int main()&&&&{&&&& &&&& cin&&n;&&&& while(n--)&&&& {&&&&
int num,i,j;
if(num==1)&&&&
cout&&"2 1"&&&&&&
for(i=!isprime(i);i--); &&&&
for(j=!isprime(j);j++); &&&&
if((num-i)&(j-num))&&&&
cout&&i&&' '&&(num-i)&&&&&&
else if((num-i)&(j-num))&&&&
cout&&j&&' '&&(j-num)&&&&&&
else if((num-i)==(j-num))&&&&
cout&&i&&' '&&(num-i)&&&&&& }&&&&}
&&&&25、&&&&A Famous Music Composer&&&&时间限制:&&&&难度:1&&&&描述 &&&&Mr.&&&& B is a famous music composer. One of his most famous work was his set &&&&of preludes. These 24 pieces span the 24 musical keys (there are &&&&musically distinct 12 scale notes, and each may use major or minor &&&&tonality). The 12 distinct scale notes are:&&&&&&&&&&&&&&&&&&&&&&A & &&&&&A#=Bb&&&&&B & & &&&&&&C & &&&&&&&C#=Db&&&&D & & &&&&&D#=Eb&&&&&E & & &&&&&F & & &&&&&&F#=Gb&&&&&G & &&&&&&&G#=Ab&&&&&&&&&&&&&&&&&&&&&&&&&&&&&Five&&&& of the notes have two alternate names, as is indicated above with &&&&equals sign. Thus, there are 17 possible names of scale notes, but only &&&&12 musically distinct notes. When using one of these as the keynote for a&&&& musical key, we can further distinguish between major and minor &&&&tonalities. This gives 34 possible keys, of which 24 are musically &&&&distinct.&&&&&In naming his preludes, Mr. B used all the keys except the following 10, which were named instead by their alternate names:&&&&&&&&&&&&&&&&&&&&&&Ab minor&&&&&A# major&&&&A# minor&&&&&C# major&&&&&Db minor&&&&&&&&&&&&&D# major&&&&&D# minor&&&&Gb major&&&&&Gb minor&&&&&G# major&&&&&&&&&&&&&&&&&&&&&&&&&&&&&Write a program that, given the name of a key, give an alternate name if it has one, or report the key name is unique.&&&&&&&&&输入Each&&&& test case is described by one line having the format "note tonality", &&&&where "note" is one of the 17 names for the scale notes given above, and&&&& "tonality" is either "major" or "minor" (quotes for clarify).输出For each case output the required answer, following the format of the sample.样例输入&&&&Ab minor&&&&D# major&&&&G minor&&&&样例输出&&&&Case 1: G# minor&&&&Case 2: Eb major&&&&Case 3: UNIQUE&&&&来源hdu上传者李如兵&&&& &&&&#include &stdio.h&&&&&#include &string.h&&&&&#include &algorithm&&&&&&&&&char str[100];&&&&int cas = 1;&&&&int main()&&&&{&&&&
while(gets(str))&&&&
printf("Case %d: ",cas++);&&&&
int i,j,&&&&
len = strlen(str);&&&&
if(str[1] == ' ')&&&&
printf("UNIQUE\n");&&&&
if(str[1] == '#')&&&&
if(str[0] == 'G')&&&&
printf("Ab");&&&&
printf("%cb",str[0]+1);&&&&
else if(str[1] == 'b')&&&&
if(str[0] == 'A')&&&&
printf("G#");&&&&
printf("%c#",str[0]-1);&&&&
for(i = 2;i&i++)&&&&
printf("%c",str[i]);&&&&
printf("\n");&&&&
return 0;&&&&}&&&& &&&&#include&iostream&//最优程序&&&&#include&string&&&&&&&&&string trans(string a){&&&& string b="";&&&& if(a[1]=='#'){&&&&
b+=char((a[0]-'A'+1)%7+'A');&&&&
b+='b';&&&& }else{&&&&
b+=char((a[0]-'A'+6)%7+'A');&&&&
b+='#';&&&& }&&&& &&&&}&&&&int main(){&&&& string a,b;&&&& for(int t=1; cin&&a&&b; t++){&&&&
cout&&"Case "&&t&&": ";&&&&
if(a.length()==1)&&&&
cout&&"UNIQUE"&&&&&&
cout&&trans(a)&&" "&&b&&&&&& }&&&& return 0;&&&&}&&&&
&&&&31、&&&&5个数求最值&&&&时间限制:&&&&难度:1&&&&描述 设计一个从5个整数中取最小数和最大数的程序输入输入只有一组测试数据,为五个不大于1万的正整数输出输出两个数,第一个为这五个数中的最小值,第二个为这五个数中的最大值,两个数字以空格格开。样例输入&&&&1 2 3 4 5&&&&样例输出&&&&1 5&&&&来源C语言课本第四章第一题上传者张云聪&&&&#include&stdio.h&&&&&int main() {&&&& int a[5], temp, i,&&&& for (i = 0; i & 5; i++)&&&&
scanf("%d", &a[i]);&&&& for (j = 0; j & 5; j++)&&&&
for (i = 0; i & 4; i++)&&&&
if (a[i] & a[i + 1]) {&&&&
temp = a[i];&&&&
a[i] = a[i + 1];&&&&
a[i + 1] =&&&&
}&&&& printf("%d %d", a[0], a[4]);&&&& return 0;&&&&}&&&&&&&&&#include&iostream&//最优程序&&&&#include&iterator&&&&&#include&algorithm&&&&&&&&&int main()&&&&{&&&&&& &int a[5];&&&&&& &copy(istream_iterator&int&(cin),istream_iterator&int&(),a);&&&&&& &cout&&*min_element(a,a+5)&&" "&&*max_element(a,a+5)&&&&&&}&&&&&&& &&&&&&&&33、&&&&蛇形填数&&&&时间限制:&&&&难度:3&&&&描述 在n*n方陈里填入1,2,...,n*n,要求填成蛇形。例如n=4时方陈为:10 11 12 19 16 13 28 15 14 37 6 5 4输入直接输入方陈的维数,即n的值。(n&=100)输出输出结果是蛇形方陈。样例输入&&&&3&&&&样例输出&&&&7 8 1&&&&6 9 2&&&&5 4 3&&&&来源算法经典上传者首席执行官&&&& &&&&#include"stdio.h"&&&&#include&stdlib.h&&&&&int main()&&&&{&&&&
int a[109][109]= {0},i,j,k,n,m,top,x,y;&&&&
top=1;&&&&
scanf("%d",&n);&&&&
a[x=0][y=n-1]=1;&&&&
while(top&n*n)&&&&
while(x+1&n&&!a[x+1][y]) a[++x][y]=++&&&&
while(y-1&=0&&!a[x][y-1]) a[x][--y]=++&&&&
while(x-1&=0&&!a[x-1][y]) a[--x][y]=++&&&&
while(y+1&n&&!a[x][y+1]) a[x][++y]=++&&&&
for(i=0; i&n; i++)&&&&
for(j=0; j&n; j++)&&&&
printf("%d ",a[i][j]);&&&&
printf("\n");&&&&
//system("33.exe\n");&&&&}&&&&&&&&&#include&stdio.h&//最优程序&&&&int main()&&&&{&&&&&& &int a,b,c,d,n,sum=1;&&&&&& &int yi[101][101];&&&&&& &scanf("%d",&n);&&&&&& &for(a=0;a&=(n-1)/2;a++)&&&&&& &{&&&&&& &&& &for(b=a;b&=n-a-1;b++)&&&&&& &&& &&& &yi[b][n-a-1]=sum++;&&&&&& &&& &for(b=n-2-a;b&=a;b--)&&&&&& &&& &&& &yi[n-a-1][b]=sum++;&&&&&& &&& &for(b=n-a-2;b&=a;b--)&&&&&& &&& &&& &yi[b][a]=sum++;&&&&&& &&& &for(b=a+1;b&n-a-1;b++)&&&&&& &&& &&& &yi[a][b]=sum++;&&&&&& &}&&&&&& &for(c=0;c&n;c++)&&&&&& &{&&&&&& &&& &for(d=0;d&n;d++)&&&&&& &&& &&& &printf("%d ",yi[c][d]);&&&&&& &&& &printf("\n");&&&&&& &}&&&&}&&&&&&& &&&&
&&&&34、&&&&韩信点兵&&&&时间限制:&&&&难度:1&&&&描述 相&&&&传韩信才智过人,从不直接清点自己军队的人数,只要让士兵先后以三人一排、五人一排、七人一排地变换队形,而他每次只掠一眼队伍的排尾就知道总人数了。输&&&&入3个非负整数a,b,c &&&&,表示每种队形排尾的人数(a&3,b&5,c&7),输出总人数的最小值(或报告无解)。已知总人数不小于10,不超过100 。输入输入3个非负整数a,b,c ,表示每种队形排尾的人数(a&3,b&5,c&7)。例如,输入:2 4 5输出输出总人数的最小值(或报告无解,即输出No answer)。实例,输出:89样例输入&&&&2 1 6&&&&样例输出&&&&41&&&&来源经典算法上传者首席执行官&&&& &&&& &&&&#include&iostream&&&&&&&&&int main()&&&&{&&&& int a,b,c;&&&& cin&&a&&b&&c;&&&& int n=(a*70+b*21+c*15)%105;&&&& if(n&100||n&10) cout&&"No answer"&&&&&& else cout&&n&&&&&&}
&&&&39、&&&&水仙花数&&&&时间限制:&&&&难度:0&&&&描述 请判断一个数是不是水仙花数。其中水仙花数定义各个位数立方和等于它本身的三位数。输入有多组测试数据,每组测试数据以包含一个整数n(100&=n&1000)输入0表示程序输入结束。输出如果n是水仙花数就输出Yes否则输出No样例输入&&&&153&&&&154&&&&0&&&&样例输出&&&&Yes&&&&No&&&&来源C语言课本习题改编上传者张云聪&&&& &&&&#include "stdio.h"&&&&int main(int argc, char const *argv[])&&&&{&&&&
int n=0;&&&&
//freopen("input.txt","r",stdin);&&&&
while(scanf("%d",&n)==1)&&&&
if(n!=0)&&&&
if (n==153||n==370||n==371||n==407) printf("Yes\n");&&&&
else printf("No\n");&&&&
return 0;&&&&}&&&& &&&&&#include&iostream&//最优程序&&&&&&&&int main()&&&&{&&&&&& &&&&&&& &while(1)&&&&&& &{&&&&&& &&& &cin&&a;&&&&&& &&& &if(a==0)&&&&&& &&& &cout&&((a==153||a==370||a==371||a==407)?"Yes":"No")&&&&&&&& &}&&&&}&&&&&&& &&&&
&&&&40、&&&&公约数和公倍数&&&&时间限制:&&&&难度:1&&&&描述 小明被一个问题给难住了,现在需要你帮帮忙。问题是:给出两个正整数,求出它们的最大公约数和最小公倍数。输入第一行输入一个整数n(0&n&=10000),表示有n组测试数据;随后的n行输入两个整数i,j(0&i,j&=32767)。输出输出每组测试数据的最大公约数和最小公倍数样例输入&&&&3&&&&6 6&&&&12 11&&&&33 22&&&&&&&&样例输出&&&&6 6&&&&1 132&&&&11 66&&&&来源[苗栋栋]原创上传者苗栋栋&&&&#include&stdio.h&&&&&int main() {&&&& int a, b, c, n,&&&& scanf("%d", &n); //输入一个整数n(0&n&=10000),表示有n组测试数据 &&&& while (n--) {&&&&
scanf("%d %d", &a, &b); //输入两个整数 &&&&
k = a *&&&&
while (b != 0) {&&&&
c = a %&&&&
printf("%d %d\n", a, k / a);&&&& }&&&& return 0;&&&&}&&&&&&&&&import java.io.*;&&&&import java.util.*;&&&&public class Main {&&&&&& &public static int gcd(int a, int b) {&&&&&& &&& &return b == 0 ? a : gcd(b, a % b);&&&&&& &}&&&&&& &public static Scanner count = new Scanner(System.in);&&&&&& &public static void main(String[] arges) {&&&&&& &&& &int n = count.nextInt();&&&&&& &&& &while ((n--) & 0) {&&&&&& &&& &&& &int a = count.nextInt(), b = count.nextInt();&&&&&& &&& &&& &System.out.println(gcd(a, b) + " " + a * b / gcd(a, b));&&&&&& &&& &}&&&&&& &&& &count.close();&&&&&& &}&&&&}&&&&&&&&&&& &&&&&&&&&#include&stdio.h&&&&&int main()&&&&{&&&&&& &unsigned int u,v,r,s,i,d;&&&&&& &scanf("%u",&s);&&&&&& &for(i=1;i&=s;i++)&&&&&& &{&&&&&& &&& &scanf("%u%u",&u,&v);&&&&&& &&& &d=u*v;&&&&&& &&& &while(v!=0)&&&&&& &&& &{&&&&&& &&& &&& &r=u%v;&&&&&& &&& &&& &u=v;&&&&&& &&& &&& &v=r;&&&&&& &&& &}&&&&&& &&& &printf("%u %u\n",u,d/u);&&&&&& &}&&&&&& &return 0;&&&&}&&&&&&& &&&&&&&&41、&&&&三个数从小到大排序&&&&时间限制:&&&&难度:0&&&&描述 &&&&现在要写一个程序,实现给三个数排序的功能&&&&输入输入三个正整数输出给输入的三个正整数排序样例输入&&&&20 7 33&&&&样例输出&&&&7 20 33&&&&来源[张洁烽]原创上传者张洁烽&&&&import java.util.S&&&&public class Main&&&&{&&&&public static void main(String[] args)&&&& {&&&&
int a,b,c,n;&&&&
Scanner num=new Scanner(System.in);&&&&
System.out.print("");&&&&
a=num.nextInt();&&&&
System.out.print("");&&&&
b=num.nextInt();&&&&
System.out.print("");&&&&
c=num.nextInt();&&&&
if(a&b) {&&&&
n=a;a=b;b=n;&&&&
if(b&c) {&&&&
n=b;b=c;c=n;&&&&
if(a&c) {&&&&
n=a;a=c;c=n;&&&&
System.out.println(a+" "+b+" "+c);&&&& }&&&&}&&&&&&&&&#include &stdio.h&//最优程序&&&&int main()&&&&{&&&&&& &int a,b,c,an[3],i,t,j,max,&&&&&& &scanf ("%d %d %d",&an[0],&an[1],&an[2]);&&&&&& &for (i=0;i&3;i++)&&&&&& &{&&&&&& &&& &t=max=an[i];&&&&&& &&& &flag=i;&&&&&& &&& &for (j=i;j&3;j++)&&&&&& &&& &&& &if (an[j]&t) &&&&&& &&& &&& &{&&&&&& &&& &&& &&& &max=an[j];&&&&&& &&& &&& &&& &flag=j;&&&&&& &&& &&& &};&&&&&& &&& &t=an[i];&&&&&& &&& &an[i]=&&&&&& &&& &an[flag]=t;&&&&&& &}&&&&&& &for (i=2;i&=0;i--)&&&&&& &&& &printf ("%d ",an[i]);&&&&&& &return 0;&&&&}&&&&&&&&&&&&&&&&&&&56、&&&&阶乘因式分解(一)&&&&时间限制:&&&&难度:2&&&&描述 输入第一行是一个整数s(0&s&=100),表示测试数据的组数随后的s行, 每行有两个整数n,m。输出输出m的个数。样例输入&&&&2&&&&100 5&&&&16 2&&&&&&&&样例输出&&&&24&&&&15&&&&&&&&来源网络上传者苗栋栋&&&&#include &stdio.h&&&&&int main(void) {&&&& int N, n, m,&&&& scanf("%d", &N);&&&& while (N--) {&&&&
count = 0;&&&&
scanf("%d%d", &n, &m);&&&&
while (n) {&&&&
n = n /&&&&
count = count +&&&&
printf("%d\n", count);&&&& }&&&& return 0;&&&&}&&&&&&&&&#include&iostream&//最优程序&&&&&&&&int get(int n,int num)&&&&{&&&&&& &if(n==0) return 0;&&&&&& &else return get(n/num,num)+n/&&&&}&&&&int main()&&&&{&&&&&& &&&&&&& &cin&&n;&&&&&& &while(n--)&&&&&& &{&&&&&& &&& &int a,b;&&&&&& &&& &cin&&a&&b;&&&&&& &&& &cout&&get(a,b)&&&&&&&& &}&&&&}&&&&&&& &&&&&&&&57、&&&&6174问题&&&&时间限制:&&&&难度:2&&&&描述 &&&&假&&&&设你有一个各位数字互不相同的四位数,把所有的数字从大到小排序后得到a,从小到大后得到b,然后用a-b替换原来这个数,并且继续操作。例如,从&&&&1234出发,依次可以得到87、2、74,又回到了它自己!现在要你写一个&&&&程序来判断一个四位数经过多少次这样的操作能出现循环,并且求出操作的次数&&&&比如输入1234执行顺序是-&-&6174,输出是4&&&&输入第一行输入n,代表有n组测试数据。接下来n行每行都写一个各位数字互不相同的四位数输出经过多少次上面描述的操作才能出现循环样例输入&&&&1&&&&1234&&&&样例输出&&&&4&&&&来源[张洁烽]原创上传者张洁烽&&&& &&&&#include&stdio.h&&&&&int main()&&&&{&&&&
int n,m,a[4],i,j,count,max,min,t;&&&&
scanf("%d",&n);&&&&
while(n--)&&&&
count=1;&&&&
scanf("%d",&m);&&&&
while(m!=6174)&&&&
for(i=0; i&4; i++)&&&&
a[i]=m%10;&&&&
m=m/10;&&&&
for(i=0; i&4; i++)&&&&
for(j=i+1; j&4; j++)&&&&
if(a[i]&a[j])&&&&
t=a[i];&&&&
a[i]=a[j];&&&&
a[j]=t;&&&&
max=a[0]*1000+a[1]*100+a[2]*10+a[3];&&&&
min=a[3]*1000+a[2]*100+a[1]*10+a[0];&&&&
m=max-&&&&
count++;&&&&
printf("%d\n",count);&&&&
return 0;&&&&}&&&& &&&&&#include&iostream&//最优程序&&&&#include&algorithm&&&&&#include&stdio.h&&&&&&&&&int main()&&&&{&&&&&& &//freopen("1.txt","r",stdin);&&&&&& &&&&&&& &cin&&k;&&&&&& &while(k--)&&&&&& &{&&&&&& &&& &int n,a[4],n1,n2;&&&&&& &&& &scanf("%d",&n);&&&&&& &&& &int s=1;&&&&&& &&& &while(n!=6174)&&&&&& &&& &{&&&&&& &&& &&& &a[0]=n%10;&&&&&& &&& &&& &a[3]=n/1000;&&&&&& &&& &&& &a[1]=n/10%10;&&&&&& &&& &&& &a[2]=n/100%10;&&&&&& &&& &&& &sort(a,a+4);&&&&&& &&& &&& &n1=1000*a[3]+100*a[2]+10*a[1]+a[0];&&&&&& &&& &&& &n2=1000*a[0]+100*a[1]+10*a[2]+a[3];&&&&&& &&& &&& &n=n1-n2;&&&&&& &&& &&& &s++;&&&&&& &&& &}&&&&&& &&& &printf("%d\n",s);&&&&&& &}&&&&}&&&&&&& &&&&
&&&&60、&&&&谁获得了最高奖学金&&&&时间限制:&&&&难度:2&&&&描述 &&&&某校的惯例是在每学期的期末考试之后发放奖学金。发放的奖学金共有五种,获取的条件各自不同:  1) 院士奖学金,每人8000元,期末平均成绩高于80分(&80),并且在本学期内发表1篇或1篇以上论文的学生均可获得;  2) 五四奖学金,每人4000元,期末平均成绩高于85分(&85),并且班级评议成绩高于80分(&80)的学生均可获得;  3) 成绩优秀奖,每人2000元,期末平均成绩高于90分(&90)的学生均可获得;  4) 西部奖学金,每人1000元,期末平均成绩高于85分(&85)的西部省份学生均可获得;  5) 班级贡献奖,每人850元,班级评议成绩高于80分(&80)的学生干部均可获得;  只要符合条件就可以得奖,每项奖学金的获奖人数没有限制,每名学生也可以同时获得多项奖学金。例如姚林的期末平均成绩是87分,班级评议成绩82分,同时他还是一位学生干部,那么他可以同时获得五四奖学金和班级贡献奖,奖金总数是4850元。  现在给出若干学生的相关数据,请计算哪些同学获得的奖金总数最高(假设总有同学能满足获得奖学金的条件)。输入第&&&&一行输入数据N,表示测试数据组数(0&N&100),每组测试数据输入的第一行是一个整数X(1 &= X &= &&&&100),表示学生的总数。接下来的X行每行是一位学生的数据,从左向右依次是姓名,期末平均成绩,班级评议成绩,是否是学生干部,是否是西部省份学生,&&&&以及发表的论文数。姓名是由大小写英文字母组成的长度不超过20的字符串(不含空格);期末平均成绩和班级评议成绩都是0到100之间的整数(包括0和&&&&100);是否是学生干部和是否是西部省份学生分别用一个字符表示,Y表示是,N表示不是;发表的论文数是0到10的整数(包括0和10)。每两个相邻数&&&&据项之间用一个空格分隔。输出  每组测试数据输出包括三行,第一行是获得最多奖金的学生的姓名,第二行是这名学生获得的奖金总数。如果有两位或两位以上的学生获得的奖金最多,输出他们之中在输入文件中出现最早的学生的姓名。第三行是这X个学生获得的奖学金的总数。样例输入&&&&1&&&&4&&&&YaoLin 87 82 Y N 0&&&&ChenRuiyi 88 78 N Y 1&&&&LiXin 92 88 N N 0&&&&ZhangQin 83 87 Y N 1&&&&样例输出&&&&ChenRuiyi&&&&9000&&&&28700&&&&来源NOIP2005上传者hzyqazasdf&&&& &&&&#include &iostream&&&&&&&&&int main(void)&&&&{&&&&
string str,_&&&&
char ca,&&&&
int n,m,x,y,z,s,sum,&&&&
cin&&n;&&&&
while(n--)&&&&
cin&&m;&&&&
max = sum = 0;&&&&
while(m--)&&&&
s = 0;&&&&
cin&&str&&x&&y&&ca&&cb&&z;&&&&
if(x&80&&z&0)&&&&
s += 8000;&&&&
sum += 8000;&&&&
if(x&85&&y&80)&&&&
s += 4000;&&&&
sum += 4000;&&&&
if(x&90)&&&&
s += 2000;&&&&
sum += 2000;&&&&
if(x&85&&cb == 'Y')&&&&
s += 1000;&&&&
sum += 1000;&&&&
if(y&80&&ca == 'Y')&&&&
s += 850;&&&&
sum += 850;&&&&
if(max & s)&&&&
_str =&&&&
cout&&_str&&endl&&max&&endl&&sum&&&&&&
&&&&&&&&&#include&iostream&//最优程序&&&&#include&string&&&&&#include&algorithm&&&&&#include&numeric&&&&&&&&&int calc(int qm,int py,bool gb,bool xb,bool lw)&&&&{&&&&&& &int all=0;&&&&&& &if(qm&80 && lw) all+=8000;&&&&&& &if(qm&85&& py&80) all+=4000;&&&&&& &if(qm&90) all+=2000;&&&&&& &if(xb&&qm&85) all+=1000;&&&&&& &if(gb&&py&80) all+=850;&&&&&& &&&&&}&&&&int main()&&&&{&&&&&& &&&&&&& &cin&&n;&&&&&& &while(n--)&&&&&& &{&&&&&& &&& &&&&&&& &&& &cin&&m;&&&&&& &&& &int max_num=0,all=0;&&&&&& &&& &string max_&&&&&& &&& &while(m--)&&&&&& &&& &{&&&&&& &&& &&& &int qm,py,&&&&&& &&& &&& &string xm,gbs,&&&&&& &&& &&& &cin&&xm&&qm&&py&&gbs&&xbs&&&&&&&& &&& &&& &bool gb=gbs=="Y",xb=xbs=="Y";&&&&&& &&& &&& &int num=calc(qm,py,gb,xb,lw&0);&&&&&& &&& &&& &all+=&&&&&& &&& &&& &if(num&max_num) {max_num=max_stu=}&&&&&& &&& &}&&&&&& &&& &cout&&max_stu&&endl&&max_num&&endl&&all&&&&&&&& &}&&&&}&&&&&&& &&&&
&&&&62、&&&&笨小熊&&&&时间限制:&&&&难度:2&&&&描述 &&&&笨小熊的词汇量很小,所以每次做英语选择题的时候都很头疼。但是他找到了一种方法,经试验证明,用这种方法去选择选项的时候选对的几率非常大! 这种方法的具体描述如下:假设maxn是单词中出现次数最多的字母的出现次数,minn是单词中出现次数最少的字母的出现次数,如果maxn-minn是一个质数,那么笨小熊就认为这是个Lucky Word,这样的单词很可能就是正确的答案。&&&&输入第一行数据N(0&N&100)表示测试数据组数。每组测试数据输入只有一行,是一个单词,其中只可能出现小写字母,并且长度小于100。 输出每组测试数据输出共两行,第一行是一个字符串,假设输入的的单词是Lucky Word,那么输出&Lucky Word&,否则输出&No Answer&; 第二行是一个整数,如果输入单词是Lucky Word,输出maxn-minn的值,否则输出0样例输入&&&&2&&&&error&&&&olympic&&&&样例输出&&&&Lucky Word&&&&2&&&&No Answer&&&&0&&&&来源NOIP2008上传者hzyqazasdf&&&& &&&&#include&iostream&&&&&#include&string&&&&&&&&&int prime_number(int n)&&&&{&&&&
if(n==1||n==0)return 0;&&&&
if(n==2)return 1;&&&&
for(int i=2;i*i&=n;i++)&&&&
if(n%i==0)return 0;&&&&
return 1;&&&&}&&&&int maxn_minn(string a)&&&&{&&&&
int b[101]={0};&&&&
for(int i=0; i&a.size(); i++)&&&&
for(int j=0; j&a.size(); j++)&&&&
if(a[i]==a[j])&&&&
b[i]++;&&&&
int maxn=b[0];&&&&
int minn=b[0];&&&&
for(int i=0;i&a.size();i++)&&&&
if(b[i]&maxn)maxn=b[i];&&&&
if(b[i]&minn)minn=b[i];&&&&
return maxn-&&&&}&&&&int main()&&&&{&&&&&&&&
cin&&n;&&&&
while(n--)&&&&
cin&&a;&&&&
prime_number(maxn_minn(a))==1?cout&&"Lucky Word\n"&&maxn_minn(a)&&endl:cout&&"No Answer\n"&&"0"&&&&&&
return 0;&&&&}&&&& &&&&&#include&iostream&//最优程序&&&&#include&string&&&&&#include&algorithm&&&&&#include&numeric&&&&&&&&&bool isPrime(int n)&&&&{&&&&&& &if(n==0)&&&&&& &if(n==1)&&&&&& &if(n==2)&&&&&& &for(int i=2;i*i&=n;i++)&&&&&& &{&&&&&& &&& &if(n%i==0)&&&&&& &}&&&&&& &&&&&}&&&&int min_e(int *p,int *q)&&&&{&&&&&& &int m=1000;&&&&&& &for(int* i=p;i!=q;i++)&&&&&& &{&&&&&& &&& &if(*i&m && *i!=0) m=*i;&&&&&& &}&&&&&& &&&&&}&&&&int main()&&&&{&&&&&& &&& &&&&&&& &&&&&&& &cin&&n;&&&&&& &while(n--)&&&&&& &{&&&&&& &&& &int count[26]={0};&&&&&& &&& &cin&&&&&&&& &&& &for(int i=0;i!=str.size();++i)&&&&&& &&& &{&&&&&& &&& &&& &++count[str[i]-'a'];&&&&&& &&& &}&&&&&& &&& &int nn=*max_element(count,count+26)-min_e(count,count+26);&&&&&& &&& &if(isPrime(nn)) cout&&"Lucky Word"&&endl&&nn&&&&&&&& &&& &else cout&&"No Answer"&&endl&&0&&&&&&&& &}&&&&}&&&&&&& &&&&
&&&&64、&&&&鸡兔同笼&&&&时间限制:&&&&难度:1&&&&描述 已知鸡和兔的总数量为n,总腿数为m。输入n和m,依次输出鸡和兔的数目,如果无解,则输出&No answer&(不要引号)。输入第一行输入一个数据a,代表接下来共有几组数据,在接下来的(a&10)a行里,每行都有一个n和m.(0&m,n&100)输出输出鸡兔的个数,或者No answer样例输入&&&&2&&&&14 32&&&&10 16&&&&&&&&样例输出&&&&12 2&&&&No answer&&&&来源[张洁烽]原创上传者张洁烽&&&& &&&&#include "stdio.h"&&&&int main(int argc, char const *argv[])&&&&{&&&& int i,m,n,N;&&&& scanf("%d",&N);&&&& while(N--)&&&& {&&&&
int x,y,a=0;&&&&
scanf("%d%d",&n,&m);&&&&
for(i=0;i&=n;i++)&&&&
if(i*2+(n-i)*4==m)&&&&
printf("%d %d\n",i,n-i);&&&&
if(a==0)printf("No answer\n");&&&& }&&&& return 0;&&&&} &&&&&&&&&#include&iostream&//最优程序&&&&&&&&int main()&&&&{&&&&&& int n,a,b,p,q;&&&&&& cin&&n;&&&&&& while(n--)&&&&&& {&&&&&&&&& cin&&a&&b;&&&&&&&&& q=(b-2*a)/2;&&&&&&&&& p=a-q;&&&&&&&&& if(p&0 ||q&0 || b%2) cout&&"No answer"&&&&&&&&&&& else cout&&p&&" "&&q&&&&&&&& }&&&&}&&&&&&&&&&&&&&&&&&&&&&& &&&&
&&&&65、&&&&另一种阶乘问题&&&&时间限制:&&&&难度:1&&&&描述 &&&&大家都知道阶乘这个概念,举个简单的例子:5!=1*2*3*4*5.现在我们引入一种新的阶乘概念,将原来的每个数相乘变为i不大于n的所有奇数相乘例如:5!!=1*3*5.现在明白现在这种阶乘的意思了吧!&&&&现在你的任务是求出1!!+2!!......+n!!的正确值(n&=20)&&&&输入第一行输入一个a(a&=20),代表共有a组测试数据接下来a行各行输入一个n.输出各行输出结果一个整数R表示1!!+2!!......+n!!的正确值样例输入&&&&2&&&&3&&&&5&&&&样例输出&&&&5&&&&23&&&&来源[张洁烽]原创上传者张洁烽&&&& &&&&#include &stdio.h&&&&&int f(int n) {&&&&&& &int i, s = 1;&&&&&& &for (i = 1; i &= i += 2)&&&&&& &&& &s *=&&&&&& &&&&&}&&&&int main() {&&&&&& &int a, n, i,&&&&&& &scanf("%d", &a);&&&&&& &while (a--) {&&&&&& &&& &s = 0;&&&&&& &&& &scanf("%d", &n);&&&&&& &&& &for (i = 1; i &= i++)&&&&&& &&& &&& &s += f(i);&&&&&& &&& &printf("%d\n", s);&&&&&& &}&&&&&& &return 0;&&&&}
&&&&&&&&&/*&&&&#include&iostream&&&&&&&&&int f(int n)&&&&{&&&&&& &if(n%2) return n==1?1:n*f(n-2);&&&&&& &return f(n-1);&&&&}&&&&int g(int n)&&&&{&&&&&& &return n?g(n-1)+f(n):0;&&&&}&&&&int main()&&&&{&&&&&& &int n,m;&&&&&& &cin&&n;&&&&&& &while(n--)&&&&&& &{&&&&&& &&& &cin&&m;&&&&&& &&& &cout&&g(m)&&&&&&&& &}&&&&}*/&&&&#include&iostream&//最优程序&&&&&&&&int main()&&&&{&&&&&& &int n,m,r[]={0,1,2,5,8,23,38,143,248,533,,,173,};&&&&&& &cin&&n;&&&&&& &while(n--)&&&&&& &{&&&&&& &&& &cin&&m;&&&&&& &&& &cout&&r[m]&&&&&&&& &}&&&&}&&&&&&& &&&&
&&&&72、&&&&Financial Management&&&&时间限制:&&&&难度:1&&&&描述 Larry&&&& graduated this year and finally has a job. He's making a lot of money, &&&&but somehow never seems to have enough. Larry has decided that he needs &&&&to grab hold of his financial portfolio and solve his financing &&&&problems. The first step is to figure out what's been going on with his &&&&money. Larry has his bank account statements and wants to see how much &&&&money he has. Help Larry by writing a program to take his closing &&&&balance from each of the past twelve months and calculate his average &&&&account balance.输入The input will be &&&&twelve lines. Each line will contain the closing balance of his bank &&&&account for a particular month. Each number will be positive and &&&&displayed to the penny. No dollar sign will be included.输出The&&&& output will be a single number, the average (mean) of the closing &&&&balances for the twelve months. It will be rounded to the nearest penny,&&&& preceded immediately by a dollar sign, and followed by the end-of-line.&&&& There will be no other spaces or characters in the output. 样例输入&&&&100.00&&&&489.12&&&&12454.12&&&&1234.10&&&&823.05&&&&109.20&&&&5.27&&&&1542.25&&&&839.18&&&&83.99&&&&1295.01&&&&1.75&&&&&&&&样例输出&&&&1581.42&&&&来源[张洁烽]原创上传者张洁烽&&&& &&&&#include "stdio.h"&&&&int main(int argc, char const *argv[])&&&&{&&&&
double sum=0,a;&&&&
int n=12;&&&&
// freopen("input.txt","r",stdin);&&&&
while(n--)&&&&
scanf("%lf",&a);&&&&
sum+=a;&&&&
printf("%.2lf\n",sum/12);&&&&
return 0;&&&&}&&&&
&&&&&#include&iostream&//最优程序&&&&#include&iomanip&&&&&&&&&int main()&&&&{&&&&&& &double sum=0,a;&&&&&& &for(int i=0;i&12;i++)&&&&&& &{&&&&&& &&& &cin&&a;&&&&&& &&& &sum+=a;&&&&&& &}&&&&&& &cout&&fixed&&setprecision(2)&&sum/12.0&&&&&&}&&&&&&& &&&&
&&&&74、&&&&小学生算术&&&&时间限制:&&&&难度:1&&&&描述 很多小学生在学习加法时,发现&进位&特别容易出错。你的任务是计算两个三位数在相加时需要多少次进位。你编制的程序应当可以连续处理多组数据,直到读到两个0(这是输入结束标记)。输入输入两个正整数m,n.(m,n,都是三位数)输出输出m,n,相加时需要进位多少次。样例输入&&&&123 456&&&&555 555&&&&123 594&&&&0 0&&&&样例输出&&&&0&&&&3 &&&&1&&&&&&&&来源[张洁烽]原创上传者张洁烽&&&& &&&&#include &stdio.h&&&&&int main()&&&&{&&&&
int m,n,i,j;&&&&
int a[3],b[3];&&&&
while(scanf("%d%d",&m,&n),m!=0||n!=0)&&&&
a[0]=m/100;&&&&
a[1]=(m-100*a[0])/10;&&&&
a[2]=m%10;&&&&
b[0]=n/100;&&&&
b[1]=(n-100*b[0])/10;&&&&
b[2]=n%10;&&&&
for(i=2; i&=0; i--)&&&&
if(a[i]+b[i]&=10)&&&&
a[i-1]+=1;//要考虑进位问题&&&&
printf("%d\n",j);&&&&
return 0;&&&&}
&&&&&&&&&&&&&&#include&stdio.h&&&&&int main()&&&&{&&&&&& &int a,b,c,d,e,f,n,m,i;&&&&&& &for(;;)&&&&&& &{&&&&&& &&& &scanf("%d%d",&n,&m);&&&&&& &&& &if(n==0&&m==0)&&&&&& &&& &&& &return 0;&&&&&& &&& &else&&&&&& &&& &{&&&&&& &&& &&& &i=0;&&&&&& &&& &&& &a=n/100;b=n%100/10;c=n%10;&&&&&& &&& &&& &d=m/100;e=m%100/10;f=m%10;&&&&&& &&& &&& &if(c+f&=10)&&&&&& &&& &&& &{i+=1;b+=1;}&&&&&& &&& &&& &if(b+e&=10)&&&&&& &&& &&& &{i+=1;a+=1;}&&&&&& &&& &&& &if(a+d&=10)&&&&&& &&& &&& &{i+=1;}&&&&&& &&& &&& &printf("%d\n",i);&&&&&& &&& &}&&&&&& &}&&&&& return 0;&&&&}&&&&&&&&&&&&&&&&& &&&&
&&&&75、&&&&日期计算&&&&时间限制:&&&&难度:1&&&&描述 如题,输入一个日期,格式如: ,判断这一天是这一年中的第几天。输入第一行输入一个数N(0&N&=100),表示有N组测试数据。后面的N行输入多组输入数据,每行的输入数据都是一个按题目要求格式输入的日期。输出每组输入数据的输出占一行,输出判断出的天数n样例输入&&&&3&&&&&&&&&&&&&&&&样例输出&&&&96&&&&124&&&&297&&&&来源[naonao]改编C语言习题上传者naonao&&&& &&&&#include &iostream&&&&&&&&&int leap(int a)&&&&{&&&& if(a%4==0&&a%100!=0||a%400==0)&&&&
return 1;&&&& else return 0;&&&&}&&&&int number(int year,int m,int d)&&&&{&&&& int sum=0,i,j,k,a[12]={31,28,31,30,31,30,31,31,30,31,30,31};&&&& int b[12]={31,29,31,30,31,30,31,31,30,31,30,31};&&&& if(leap(year)==1)&&&&
for(i=0;i&m-1;i++)&&&&
sum+=b[i];&&&& else &&&&
for(i=0;i&m-1;i++)&&&&
sum+=a[i];&&&&
sum+=d;&&&&
&&&&}&&&&int main(int argc, char const *argv[])&&&&{&&&& &&&& cin&&n;&&&& while(n--)&&&& {&&&&
int year,month,day,n;&&&&
cin&&year&&month&&&&&&
n=number(year,month,day);&&&&
cout&&n&&&&&& }&&&& return 0;&&&&}
&&&&&&&&&#include&stdio.h&//最优程序&&&&int main()&&&&{&&&&&& &int a,b=0,c,y,m,d,&&&&&& &scanf("%d",&a);&&&&&& &while(a--)&&&&&& &{&&&&&& &&& &scanf("%d %d %d",&y,&m,&d);&&&&&& &&& &if(y%400==0||y%100!=0&&y%4==0)&&&&&& &&& &&& &fib=29;&&&&&& &&& &else fib=28;&&&&&& &&& &for(c=1;c&=m;c++)&&&&&& &&& &switch(c-1)&&&&&& &&& &{&&&&&&&&&&&&&& case 1:&&&&&& &&& &&& case 3:&&&&&& &&& &&& case 5:&&&&&& &&& &&& case 7:&&&&&& &&& &&& case 8:&&&&&& &&& &&& case 10:b+=31;&&&&&& &&& &&& case 2:b+=&&&&&& &&& &&& case 4:&&&&&& &&& &&& case 6:&&&&&& &&& &&& case 9:&&&&&& &&& &&& case 11:b+=30;&&&&&& &&& &}&&&&&& &&& &b+=d;&&&&&& &&& &printf("%d\n",b);&&&&&& &&& &b=0;&&&&&& &}&&&&&& &return 0;&&&&}&&&&&&& &&&&
&&&&77、&&&&开灯问题&&&&时间限制:&&&&难度:1&&&&描述 &&&&有&&&&n盏灯,编号为1~n,第1个人把所有灯打开,第2个人按下所有编号为2 的倍数的开关(这些灯将被关掉),第3 &&&&个人按下所有编号为3的倍数的开关(其中关掉的灯将被打开,开着的灯将被关闭),依此类推。一共有k个人,问最后有哪些灯开着?输入:n和k,输出开着的&&&&灯编号。k&n&1000&&&&输入输入一组数据:n和k输出输出开着的灯编号样例输入&&&&7 3&&&&样例输出&&&&1 5 6 7&&&&来源经典算法上传者首席执行官&&&& &&&&#include&stdio.h&&&&&int main( )&&&&{&&&&
int n, k, j, open,i;&&&&
scanf("%d%d", &n, &k );&&&&
for(i = 1 ; i &= i++ )&&&&
open = 1;&&&&
for( j = 2 ; j &= j++ )&&&&
if( i % j == 0 )&&&&
open = (open+1) % 2;&&&&
if( open )&&&&
printf("%d ", i );&&&&
return 0;&&&&}
&&&&&&&&&#include &iostream&//最优程序&&&&&&&&int main()&&&&{&&&&&& &int n,k,a[1000],i;&&&&&& &cin&&n&&k;&&&&&& &for(i=0;i&n;i++)&&&&&& &&& &a[i]=1;&&&&&& &for(i=2;i&=k;i++)&&&&&& &&& &for(int j=0;j&n;j++)&&&&&& &&& &{&&&&&& &&& &&& &if((j+1)%i==0)&&&&&& &&& &&& &if(a[j]==0)a[j]=1;&&&&&& &&& &&& &else a[j]=0;&&&&&& &&& &}&&&&&& &&& &for(i=0;i&n;i++)&&&&&& &&& &&& &if(a[i]==1)cout&&i+1&&" ";&&&&&& &&& &&& &cout&&&&&&&& &return 0;&&&&}&&&&&&&
&&&&94、&&&&cigarettes&&&&时间限制:&&&&难度:2&&&&描述 &&&&Tom has many cigarettes. We hypothesized that he has n cigarettes and smokes them&&&&one by one keeping all the butts. Out of k & 1 butts he can roll a new cigarette.Now,do you know how many cigarettes can Tom has? &&&&输入First&&&& input is a single line,it's n and stands for there are n testdata.then &&&&there are n lines ,each line contains two integer numbers giving the &&&&values of n and k.输出For each line of input, output one&&&& integer number on a separate line giving the maximum number of &&&&cigarettes that Peter can have.样例输入&&&&3&&&&4 3&&&&10 3&&&&100 5&&&&样例输出&&&&5&&&&14&&&&124&&&&来源[rooot]原创上传者rooot&&&& &&&&#include&iostream&&&&&&&&&int main()&&&&{&&&&cin&&n;&&&&
while(n--)&&&&
int a,b;&&&&
cin&&a&&b;&&&&
int sum=0;&&&&
sum+=a;&&&&
while(a&=b)&&&&
a-=b;//只要a-b还大于b , 就相当于a会多一个&&&&
sum++;&&&&
cout&&sum&&&&&&
return 0;&&&&}&&&&
&&&&&#include "stdio.h"&&&&#include&fstream&&&&&int main()&&&&{&&&&&& &//freopen("d:\\1.txt","r",stdin);&&&&&& &//freopen("d:\\2.txt","w",stdout);&&&&&& &&&&&&& &scanf("%d",&m);&&&&&&& while(m--)&&&&&& &{&&&&&& &&& &int n,k,&&&&&& &&& &scanf("%d%d",&n,&k);&&&&&& &&& &sum=n;&&&&&& &&& &while(n/k)&&&&&&&&&&&&&&&&& &&&&&&& &&& &{ sum+=n/k;& n=n/k+n%k; }&&&&&& &&& &printf("%d\n",sum);&&&&&& &}&&&&&& &return 0;&&&&}&&&&&&&
&&&&96、&&&&n-1位数&&&&时间限制:&&&&难度:1&&&&描述 &&&&已知w是一个大于10但不大于1000000的无符号整数,若w是n(n&2)位的整数,则求出w的后n-1位的数。&&&&输入第一行为M,表示测试数据组数。接下来M行,每行包含一个测试数据。输出输出M行,每行为对应行的n-1位数(忽略前缀0)。如果除了最高位外,其余位都为0,则输出0。样例输入&&&&4&&&&1023&&&&5923&&&&923&&&&1000&&&&样例输出&&&&23&&&&923&&&&23&&&&0&&&&来源[rooot]原创上传者rooot&&&& &&&&#include&stdio.h&&pre name="code" class="cpp"&//较简单的做法
&&&&int main()&&&&{&&&&&&&&
int M;&&&&
scanf("%d",&num);&&&&
while(num--)&&&&
scanf("%d",&M);&&&&
int i=10;&&&&
while(M/i&=10)&&&&
i=i*10;&&&&
printf( "%d\n" ,M%i);&&&&
&&&&&&&&&#include&cstdio&//最优程序&&&&int main()&&&&{&&&&&& &int n,m;&&&&&& &scanf("%d",&n);&&&&&& &while(n--)&&&&&& &{&&&&&& &&& &scanf("\n%*c%d",&m);&&&&&& &&& &printf("%d\n",m);&&&&&& &}&&&&}&&&&&&&&&&&&&&& &&&&
&&&&97、&&&&兄弟郊游问题&&&&时间限制:&&&&难度:2&&&&描述兄弟俩骑车郊游,弟弟先出发,每分钟X米,M分钟后,哥哥带一条狗出发。以每分钟Y米的速度去追弟弟,而狗则以每分钟Z米的速度向弟弟跑去,追上弟弟后又立即返回,直到哥哥追上弟弟时,狗跑了多少米?输入第一行输入一个整数N,表示测试数据的组数(N&100)每组测试数据占一行,是四个正整数,分别为M,X,Y,Z(数据保证X&Y&Z)输出输出狗跑的路径,结果保留小数点后两位。样例输入&&&&1&&&&5 10 15 20&&&&&&&&样例输出&&&&200.00&&&&来源经典数学问题上传者张云聪&&&& &&&&#include "stdio.h"&&&&int main()&&&&{&&&& &&&& scanf("%d",&n);&&&& while(n--)&&&& {&&&&
double m,x,y,z,s;&&&&
scanf("%lf%lf%lf%lf",&m,&x,&y,&z);&&&&
s=x*m/(y-x)*z;&&&&
printf("%.2lf\n",s);&&&& }&&&&
return 0;&&&&}
&&&&&&&&&#include&iostream&//最优程序&&&&#include&stdio.h&&&&&&&&&int main()&&&&{&&&&&& &&&&&&& &cin&&n;&&&&&& &while(n--)&&&&&& &{&&&&&& &&& &int s,a,b,c;&&&&&& &&& &cin&&s&&a&&b&&c;&&&&&& &&& &printf("%.2lf\n",s*a/(double)(b-a)*c);&&&&&& &}&&&&}&&&&&&&
&&&&98、&&&&成绩转换&&&&时间限制:&&&&难度:1&&&&描述 输入第一行是一个整数N,表示测试数据的组数(N&10)每组测试数据占一行,由一个整数M组成(0&=M&=100)。输出对于每组输入数据,输出一行。样例输入&&&&2&&&&97&&&&80&&&&样例输出&&&&A&&&&B&&&&来源hdu2004上传者张云聪&&&& &&&&#include "stdio.h"&&&&int main(int argc, char const *argv[])&&&&{&&&& int n,a;&&&& scanf("%d",&n);&&&& while(n--)&&&& {&&&&
scanf("%d",&a);&&&&
if(90&=a&&a&=100) printf("A\n");&&&&
if(80&=a&&a&=89) printf("B\n");&&&&
if(70&=a&&a&=79) printf("C\n");&&&&
if(60&=a&&a&=69) printf("D\n");&&&&
if(0&=a&&a&=59) printf("E\n");&&&& }&&&& return 0;&&&&}
&&&&&&&&&#include&iostream&//最优程序&&&&&&&&int main()&&&&{&&&&int n,s;&&&&cin&&n;&&&&while(n--)&&&&{&&&&cin&&s;&&&&switch(s/10)&&&&{&&&&case 10:&&&&case 9:cout&&"A"&&&&&&case 8:cout&&"B"&&&&&&case 7:cout&&"C"&&&&&&case 6:cout&&"D"&&&&&&default:cout&&"E"&&&&&&}&&&&}&&&&}&&&&&&& &&&&
&&&&100、&&&&1的个数&&&&时间限制:&&&&难度:1&&&&描述 小南刚学了二进制,他想知道一个数的二进制表示中有多少个1,你能帮他写一个程序来完成这个任务吗?输入第一行输入一个整数N,表示测试数据的组数(1&N&1000)每组测试数据只有一行,是一个整数M(0=&M&=10000)输出每组测试输出占一行,输出M的二进制表示中1的个数样例输入&&&&3&&&&4&&&&6&&&&7&&&&样例输出&&&&1&&&&2&&&&3&&&&来源[张云聪]原创上传者张云聪&&&& &&&&#include &iostream&&&&&#include &stdio.h&&&&&&&&&int main(int argc, char const *argv[])&&&&{&&&& &&&& cin&&n;&&&& while(n--)&&&& {&&&&
int a,i,count=0;&&&&
cin&&a;&&&&
while(a)&&&&
if(a%2==1) count++;&&&&
cout&&count&&&&&& }&&&& return 0;&&&&}
&&&&&&&&&#include&stdio.h&//最优程序&&&&main(){int n,m,s;scanf("%d",&n);while(n--){scanf("%d",&m);s=0;while(m)m&=m-1,s++;printf("%d\n",s);}}&&&&&&& &&&&
&&&&101、&&&&两点距离&&&&时间限制:&&&&难度:1&&&&描述&&&&输入两点坐标(X1,Y1),(X2,Y2)(0&=x1,x2,y1,y2&=1000),计算并输出两点间的距离。&&&&输入第一行输入一个整数n(0&n&=1000),表示有n组测试数据;随后每组占一行,由4个实数组成,分别表示x1,y1,x2,y2,数据之间用空格隔开。输出对于每组输入数据,输出一行,结果保留两位小数。样例输入&&&&2&&&&0 0 0 1&&&&0 1 1 0&&&&样例输出&&&&1.00&&&&1.41&&&&&&&&来源[苗栋栋]原创上传者苗栋栋&&&& &&&&#include&math.h&&&&&#include&stdio.h&&&&&int main()&&&&{&&&& &&&&
double l,x1,x2,y1,y2;&&&&
// freopen("input.txt","r",stdin);&&&&
scanf("%d",&n);&&&&
while(n--)&&&&
scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2);&&&&
l=sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));&&&&
printf("%.2lf\n",l);&&&& }&&&&
return 0;&&&&} &&&&&&&&&#include&iostream&//最优程序&&&&#include&math.h&&&&&#include&iomanip&&&&&&&&&int main()&&&&{&&&&&& &/*freopen("1.txt","r",stdin);&&&&&& &freopen("2.txt","w",stdout);*/&&&&double x1,x2,y1,y2,m;&&&&&&&&cin&&m;&&&&while(m--)&&&&{&&&&&& &cin&&x1&&y1&&x2&&y2;&&&&&&& a=sqrt((double)((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)));&&&&&& &cout.setf(ios::fixed); &&&&&&& cout&&setprecision(2)&&a&&&&&&}&&&&return 0;&&&&}&&&&
&&&&111、&&&&分数加减法&&&&时间限制:&&&&难度:2&&&&描述 编写一个C程序,实现两个分数的加减法输入输入包含多行数据 每行数据是一个字符串,格式是"a/boc/d"。 其中a, b, c, d是一个0-9的整数。o是运算符"+"或者"-"。 数据以EOF结束 输入数据保证合法输出对于输入数据的每一行输出两个分数的运算结果。 注意结果应符合书写习惯,没有多余的符号、分子、分母,并且化简至最简分数样例输入&&&&1/8+3/8&&&&1/4-1/2&&&&1/3-1/3&&&&样例输出&&&&1/2&&&&-1/4&&&&0&&&&来源水题比赛上传者hzyqazasdf&&&& &&&&#include &iostream&&&&&#include&cstdlib&&&&&&&&&int yinshu(int x,int y)&&&&{&&&&
if(x&y)&&&&
if(x%y == 0)&&&&
return abs(y);&&&&
return yinshu(y,x%y);&&&&}&&&&int main(void)//最优程序&&&&{&&&&
int a,b,c,d;&&&&
char optr,&&&&
while(cin && a && num && b && optr && c && num && d)&&&&
int x,y;&&&&
switch(optr)&&&&
case '+':&&&&
x = a*d+b*c;&&&&
y = b*d;&&&&&&&&
case '-':&&&&
x = a*d-b*c;&&&&
y = b*d;&&&&&&&&
if(x == 0)&&&&
cout && 0 &&&&&&
else if(y/yinshu(x,y) == 1)&&&&
cout && x/yinshu(x,y) &&&&&&
cout && x/yinshu(x,y) && "/" && y/yinshu(x,y) &&&&&&
return 0;&&&&}
&&&&113、&&&&字符串替换&&&&时间限制:&&&&难度:2&&&&描述 编写一个程序实现将字符串中的所有"you"替换成"we"输入输入包含多行数据 每行数据是一个字符串,长度不超过1000 数据以EOF结束输出对于输入的每一行,输出替换后的字符串样例输入&&&&you are what you do&&&&样例输出&&&&we are what we do&&&&来源水题比赛上传者hzyqazasdf&&&& &&&&#include "iostream"&&&&#include "cstring"&&&&#include "cstdio"&&&&&&&&int main(int argc, char const *argv[])&&&&{&&&&
char a[1001];&&&&
while(gets(a)!=NULL)&&&&
int i,len=0;&&&&
len=strlen(a);&&&&
for(i=0; i& i++)&&&&
if(a[i]=='y'&&a[i+1]=='o'&&a[i+2]=='u')&&&&
cout&&"we";&&&&
else cout&&a[i];&&&&
cout&&&&&&
return 0;&&&&}&&&&
&&&&&#include&algorithm&//最优程序&&&&#include&iostream&&&&&#include&string&&&&&&&&&int main()&&&&{&&&&&&& string s, s1, s2;&&&&&&& while(getline(cin,s))&&&&&&& {&&&&&&&&&&&&&&&&&&&&&& s1 = "you";&&&&&&&&&&& s2 = "we";&&&&&&&&&&& flag = s.find(s1,0);&&&&&&&&&&& while(flag != string::npos)&&&&&&&&&&& {&&&&&&&&&&&&&&& s.replace(flag, 3, s2);&&&&&&&&&&&&&&& flag = s.find(s1, flag + 1);&&&&&&&&&&& }&&&&&&&&&&& cout && s &&&&&&&&& }&&&&&&& return 0;&&&&}
&&&&122、&&&&Triangular Sums&&&&时间限制:&&&&难度:2&&&&描述 &&&&The&nth&Triangular&number,&T(n) = 1 + & +&n, is the sum of the first&n&integers. It is the number of points in a triangular array with&n&points on side. For example&T(4):&&&&XX XX X XX X X X&&&&Write a program to compute the weighted sum of triangular numbers:&&&&W(n) =&SUM[k&= 1&n;&k&*&T(k&+ 1)]&&&&输入The first line of input contains a single integer N, (1 & N & 1000) which is the number of datasets that follow.Each&&&& dataset consists of a single line of input containing a single integer &&&&n, (1 & n &300), which is the number of points on a side of the &&&&triangle.输出For each dataset, output on a single line &&&&the dataset number (1 through N), a blank, the value of n for the &&&&dataset, a blank, and the weighted sum ,W(n), of triangular numbers for &&&&n.样例输入&&&&4&&&&3&&&&4&&&&5&&&&10&&&&样例输出&&&&1 3 45&&&&2 4 105&&&&3 5 210&&&&4 10 2145&&&&来源Greater New York 2006上传者张云聪&&&& &&&&#include&iostream&&&&&&&&&int main()&&&&{&&&&
int n,j=1;&&&&
cin&&n;&&&&
while(n--)&&&&
int a,sum=0;&&&&
cin&&a;&&&&
for(int i=1;i&=a;i++)&&&&
sum+=(i*(i+1)*(i+2))/2;&&&&
cout&&j++&&" "&&a&&" "&&sum&&&&&&
return 0;&&&&}&&&&
&&&&&&&&&&#include&iostream&//最优程序&&&&&&&&const int M=310;&&&&int W[M];&&&&int main()&&&&{&&&&&& &&&&&&& &for(int i=1;i!=M;i++)&&&&&& &&& &W[i]=W[i-1]+i*(i+1)*(i+2)/2;&&&&&& &int m,n;&&&&&& &cin&&n;&&&&&& &for(int i=1;i&=n;i++)&&&&&& &{&&&&&& &&& &cin&&m;&&&&&& &&& &cout&&i&&" "&&m&&" "&&W[m]&&&&&&&& &}&&&&}&&&&&&&&&&&&&&& &&&&
&&&&125、&&&&盗梦空间&&&&时间限制:&&&&难度:2&&&&描述 &&&&《盗梦空间》是一部精彩的影片,在这部电影里,Cobb等人可以进入梦境之中,梦境里的时间会比现实中的时间过得快得多,这里假设现实中的3分钟,在梦里就是1小时。&&&&然而,Cobb他们利用强效镇静剂,可以从第一层梦境进入第二层梦境,甚至进入三层,四层梦境,每层梦境都会产生同样的时间加速效果。那么现在给你Cobb在各层梦境中经历的时间,你能算出现实世界过了多长时间吗?&&&&比如,Cobb先在第一层梦境待了1个小时,又在第二层梦境里待了1天,之后,返回第一层梦境之后立刻返回了现实。&&&&那么在现实世界里,其实过了396秒(6.6分钟)&&&&输入第一行输入一个整数T(0&=T&=100),表示测试数据的组数。每组测试数据的第一行是一个数字M(3&=M&=100)随&&&&后的M行每行的开头是一个字符串,该字符串如果是"IN" &&&&则Cobb向更深层的梦境出发了,如果是字符串"OUT"则表示Cobb从深层的梦回到了上一层。如果是首字符串是"STAY"则表示Cobb在该层梦境&&&&中停留了一段时间,本行随后将是一个整数S表示在该层停留了S分钟(1&=S&=)。数据保证在现实世界中,时间过了整数&&&&秒。输出对于每组测试数据,输出现实世界过的时间(以秒为单位)。样例输入&&&&1&&&&6&&&&IN&&&&STAY 60&&&&IN&&&&STAY 1440&&&&OUT&&&&OUT&&&&样例输出&&&&396&&&&来源通信兴趣小组选拨赛上传者admin&&&& &&&&#include &iostream&&&&&#include &string&&&&&&&&&int main() {&&&& int n,&&&& cin &&&&&& while (n--) {&&&&
double jt = 0, min, tt = 1;&&&&
cin &&&&&&
while (m--) {&&&&
cin &&&&&&
if (s == "IN") {&&&&
tt *= 20;&&&&
if (s == "OUT") {&&&&
tt /= 20;&&&&
cin &&&&&&
jt += min /&&&&
cout && jt * 60 &&&&&& }&&&& return 0;&&&&}&&&& &&&&&#include&iostream&//最优程序&&&&#include&string&&&&&&&&&int main()&&&&{&&&&&& &&&&&&& &&&&&&& &cin&&m;&&&&&& &while(m--)&&&&&& &{&&&&&& &&& &int p=1,n,t=0,&&&&&& &&& &cin&&n;&&&&&& &&& &while(n--)&&&&&& &&& &{&&&&&& &&& &&& &cin&&s;&&&&&& &&& &&& &if(s=="STAY")&&&&&& &&& &&& &{&&&&&& &&& &&& &&& &cin&&&&&&&& &&& &&& &&& &t+=tt*60/p;&&&&&& &&& &&& &}&&&&&& &&& &&& &else if(s=="IN") p*=20;&&&&&& &&& &&& &else p/=20;&&&&&& &&& &}&&&&&& &&& &cout&&t&&&&&&&& &}&&&&}&&&&&&& &&&&
&&&&168、&&&&房间安排&&&&时间限制:&&&&难度:2&&&&描述 &&&&2010&&&&年上海世界博览会(Expo2010),是第41届世界博览会。于日至10月31日期间,在中国上海市举行。本次世博会也是由中国举办的&&&&首届世界博览会。上海世博会以&城市,让生活更美好&(Better City,Better Life)为主题,将充分探索21世纪城市生活。&&&&这次世博会总投资达450亿人民币,创造了世界博览会史上的最大规模记录。吸引200个国家和国际组织参展。预计有7000万人次的参观者。&&&&为&&&&了更好地接待在这期间来自世界各地的参观者,如何合理安排各宾馆的住房问题提到了日程。组委会已接到了大量的客户住宿定单,每张定单的内容包括要住宿的房&&&&间数,开始住宿时间和要住的天数。为了便于整个城市各宾馆的管理,组委会希望对这些定单进行安排,目的是用尽可能少的房间来满足这些定单,以便空出更多的&&&&房间用于安排流动游客。&&&&组委会请求DR.Kong来完成这个任务,对这些定单进行合理安排,使得满足这些定单要求的房间数最少。&&&&假设:某个定单上的游客一旦被安排到某房间,在他预定住宿的期间内是不换房间的。为了简化描述,定单上的开始住宿时间为距离现在的第几天。例如,定单为(10,30,5)表示游客要求使用10个房间,第30天开始连住5天。&&&&输入第一行:T 表示有T组测试数据每组测试数据第一行:N 表示定单数每组测试数据接下来有N行,每行有三个整数 A B C 表示房间数,开始住宿时间和天数1&=T&=1001&=N&=10000 1&=A&=10 1&=B&=180 1&=c&=10输出输出一个整数,为满足所有定单要求的最少房间数。样例输入&&&&1&&&&3&&&&3 10 4&&&&4 9 3&&&&3 12 6&&&&样例输出&&&&7&&&&来源第三届河南省程序设计大赛上传者张云聪&&&& &&&&#include &iostream&&&&&&&&&int main() {&&&& &&&& cin&&n;&&&& while(n--){&&&&
int m,a[200]={0},b,c,d;//计算出每天的最大人数,即房间数,保存&&&&
cin&&m;&&&&
while(m--){&&&&
cin&&b&&c&&d;&&&&
for(int i=c;i&c+d;i++)//是&,第c+d天不住的&&&&
a[i]+=b;&&&&
int max=a[1];&&&&
for(int i=2;i&181;i++)&&&&
if(a[i]&max)&&&&
max=a[i];&&&&
cout&&max&&&&&& }&&&& return 0;&&&&}
&&&&&&&&&#include &stdio.h&//最优程序&&&&#include &string.h&&&&&#define MAX 200&&&&int Scan(){&&&&&&& int res=0 ,&&&&&&& while(!((ch=getchar()) &= '0' && ch &= '9'))&&&&&&&&&&& if(ch==EOF) return EOF;&&&&&& &&& &res=ch-'0';&&&&&& &&& &while((ch=getchar()) &= '0' && ch &= '9')&&&&&& &&& &&& &res = res*10 + (ch-'0');&&&&&& &&& &&&&&}&&&&int main()&&&&{&&&&&& &int Ncase,d[MAX];&&&&&& &scanf("%d",&Ncase);&&&&&& &while(Ncase--){&&&&&& &&& &memset(d,0,sizeof(d));&&&&&& &&& &int max = -1, n, a, b,&&&&&& &&& &n = Scan();&&&&&& &&& &while(n--){&&&&&& &&& &&& &a = Scan();&& &b = Scan();&& &c = Scan();&&&&&& &&& &&& &d[b] +=&&&&&& &&& &&& &d[b+c] -=&&&&&& &&& &}&&&&&& &&& &for (int i = 1 ; i & MAX ; i++){&&&&&& &&& &&& &d[i] = d[i-1] + d[i];&&&&&& &&& &&& &if (max & d[i]){&&&&&& &&& &&& &&& &max = d[i];&&&&&& &&& &&& &}&&&&&& &&& &}&&&&&& &&& &printf("%d\n",max);&&&&&& &}&&&&&& &return 0;&&&&}&&&&&&& &&&&
&&&&169、&&&&素数&&&&时间限制:&&&&难度:1&&&&描述 &&&&走进世博园某信息通信馆,参观者将获得前所未有的尖端互动体验,一场充满创想和喜悦的信息通信互动体验秀将以全新形式呈现,从观众踏入展馆的第一步起,就将与手持终端密不可分,人类未来梦想的惊喜从参观者的掌上展开。&&&&在&&&&等候区的梦想花园中,参观者便开始了他们奇妙的体验之旅,等待中的游客可利用手机等终端参与互动小游戏,与梦想剧场内的虚拟人物Kr. Kong &&&&进行猜数比赛。当屏幕出现一个整数X时,若你能比Kr. Kong更快的发出最接近它的素数答案,你将会获得一个意想不到的礼物。&&&&例如:当屏幕出现22时,你的回答应是23;当屏幕出现8时,你的回答应是7;若X本身是素数,则回答X;若最接近X的素数有两个时,则回答大于它的素数。&&&&&&&&&输入第一行:N 要竞猜的整数个数接下来有N行,每行有一个正整数X1&=N&=5 1&=X&=1000输出输出有N行,每行是对应X的最接近它的素数样例输入&&&&4&&&&22&&&&5&&&&18&&&&8&&&&样例输出&&&&23&&&&5&&&&19&&&&7&&&&来源第三届河南省程序设计大赛上传者张云聪&&&& &&&&#include&stdio.h&&&&&int main()&&&&{&&&&
int a[1010]= {1,1};&&&&
int i,j;&&&&
for(i=2; i&32; i++)&&&&
if(a[i]==0)&&&&
for(j=i*i; j&1010; j+=i)&&&&
a[j]=1;&&&&
int N;&&&&
scanf("%d",&N);&&&&
while(N--)&&&&
scanf("%d",&n);&&&&
for(i=n; a[i]==1; i--);&&&&
for(j=n; a[j]==1; j++);&&&&
if((j-n)&=(n-i))&&&&
printf("%d\n",j);&&&&
printf("%d\n",i);&&&&
}&&&&} &&&&&&&&&&&&&&#include&iostream&//最优程序&&&&#include&algorithm&&&&&&&&&int prime[]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,&&&&191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,&&&&419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,&&&&653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,&&&&919,929,937,941,947,953,967,971,977,983,991,997,1009};&&&&&& &int main()&&&&{&&&&&& &int n,m;&&&&&& &cin&&n;&&&&&& &while(n--)&&&&&& &{&&&&&& &&& &cin&&m;&&&&&& &&& &if(m==1) {cout&&2&&}&&&&&& &&& &int* l=lower_bound(prime,prime+169,m);&&&&&& &&& &if(*l-m&=m-*(l-1)) cout&&*l&&&&&&&& &&& &else cout&&*(l-1)&&&&&&&& &}&&&&}&&&&&&&&&&&&&&& &&&&
&&&&198、&&&&数数&&&&时间限制:&&&&难度:2&&&&描述 &&&&我们平时数数都是喜欢从左向右数的,但是我们的小白同学最近听说德国人数数和我们有些不同,他们正好和我们相反,是从右向左数的。因此当他看到123时会说&321&。&&&&现在有一位德国来的教授在郑州大学进行关于ACM的讲座。现在他聘请你来担任他的助理,他给你一些资料让你找到这些资料在书中的页数。现在你已经找到了对应的页码,要用英文把页码告诉他。&&&&为了简化我们的问题,你只需要返回单词的大写的首字母。(数字0读成字母O)&&&&注意:每个数字式单独读取的,因此不会出现11读成double one的情况。&&&&输入输入分两部分:第一部分:一个整数T(1&=T&=1000)第二部分:一共T行,每行为一个数字。每个数的长度不超过10位。输出每组输出单独占一行,输出对应的返回给德国教授的页码缩写。样例输入&&&&2&&&&12&&&&1234&&&&&&&&样例输出&&&&TO&&&&FTTO&&&&来源郑州大学校赛题目上传者张云聪&&&& &&&&#include&iostream&&&&&#include&string&&&&&&&&&int main ( )&&&&{&&&& &&&& cin &&&&&& while ( n-- )&&&& {&&&&
cin&&s;&&&&
for ( int i = s.size()-1; i &=0; i-- )&&&&
switch ( s[i] )&&&&
case '0':&&&&
case '1':&&&&
cout && "O";&&&&
case '2':&&&&
case '3':&&&&
cout && "T";&&&&
case '4':&&&&
case '5':&&&&
cout && "F";&&&&
case '6':&&&&
case '7':&&&&
cout && "S";&&&&
case '8':&&&&
cout && "E";&&&&
case '9':&&&&
cout && "N";&&&&
cout &&&&&& }&&&& //system ( "PAUSE" );&&&& return 0;&&&&}
&&&&&&&&&#include&cstdio&//最优程序&&&&char str[]="OOTTFFSSENT";&&&&void show(int t)&&&&{&&&&&& &if(t){putchar(*(str+t%10));show(t/10);}&&&&}&&&&int main()&&&&{&&&&&& &int n,t;&&&&&&&&&&& scanf("%d",&t);&&&&&& &while(t--)&&&&&& &{&&&&&& &&& &scanf("%d",&n);&&&&&& &&& &show(n);puts("");&&&&&& &}&&&&}&&&&&&&&&&&&&&&
&&&&199、&&&&无线网络覆盖&&&&时间限制:&&&&难度:3&&&&描述 &&&&我们的乐乐同学对于网络可算得上是情有独钟,他有一个计划,那就是用无线网覆盖郑州大学。&&&&现&&&&在学校给了他一个机会,因此他要购买很多的无线路由。现在他正在部署某条大道的网络,而学校只允许把他的无线路由器放在路的正中间。我们默认这条大道是笔&&&&直的并且它在任何地方的宽度都一样。并且所有的路由器的覆盖面积是相同的。现在乐乐计算出这条大道的长和宽,以及路由器的覆盖半径,想请你帮忙,帮他计算&&&&出他最少要购买的路由器的数量。&&&&注意:为了防止某种干扰,两台无线路由之间的最小距离不能小于1米&&&&图1中为一条矩形的道路,中间的虚线代表中线。图2为最小覆盖的示意图。&&&&&&&&&输入输入包括多组测试数据第一部分:一个整数T(1&=T&=500)第二部分:一共T行,每行包括三个整数L,D,R代表路的长,宽和覆盖半径(米)。(1&=L&=100000),(1&=D&=50),(1&=R&=200)。输出对于每组测试数据输出各占一行,只有一个整数,表示最少的路由器数量。如果不能覆盖,请输出impossible样例输入&&&&2&&&&40 6 5&&&&40 10 5&&&&样例输出&&&&5&&&&impossible&&&&来源郑州大学校赛题目上传者张云聪&&&& &&&&/*&&&& * http://acm./JudgeOnline/problem.php?pid=199&&&& * by jtahstu on
16:00&&&& */&&&&#include &iostream&&&&&#include &cmath&&&&&&&&&int main() {&&&& int r, d, l,&&&& cin &&&&&& while (n--) {&&&&
cin && l && d &&&&&&
if (4 * r * r - d * d & 1) {&&&&
cout && "impossible" &&&&&&
} else {&&&&
double a = sqrt((2 * r) * (2 * r) * 1.0 - (d * d));&&&&
if ((int) (l / a) == l / a)&&&&
cout && (int) (l / a) &&&&&&
cout && (int) (l / a) + 1 &&&&&&
}&&&& }&&&& return 0;&&&&} &&&&&&&&&#include&stdio.h&//最优程序&&&&#include&math.h&&&&&int main(){int T;double L,D,R,a;&&&&scanf("%d",&T);while(T--)&&&&{scanf("%lf%lf%lf",&L,&D,&R);&&&&a=4*R*R-D*D;if(a&0)printf("%.0lf\n",ceil(L/sqrt(a)));&&&&else puts("impossible");}}&&&&&&& &&&&
&&&&204、&&&&Coin Test&&&&时间限制:&&&&难度:1&&&&描述 &&&&As&&&& is known to all,if you throw a coin up and let it droped on the desk &&&&there are usually three results. Yes,just believe what I say ~it can be &&&&the right side or the other side or standing on the desk, If you don't &&&&believe this,just try In the past there were some famous mathematicians &&&&working on this .They repeat the throwing job once again. But jacmy is a&&&& lazy boy.He is busy with dating or playing games.He have no time to &&&&throw a single coin for 100000 times. Here comes his idea,He just go &&&&bank and exchange thousands of dollars into coins and then throw then on&&&& the desk only once. The only job left for him is to count the number of&&&& coins with three conditions.&&&&He will show you the coins on the &&&&desk to you one by one. Please tell him the possiblility of the coin on &&&&the right side as a fractional number if the possiblity between the &&&&result and 0.5 is no larger than 0.003. BE CAREFUL that even &&&&1/2,50/100,33/66 are equal only 1/2 is accepted ! if the difference &&&&between the result and 0.5 is larger than 0.003,Please tell him &&&&"Fail".Or if you see one coin standing on the desk,just say "Bingo" any &&&&way.&&&&输入Three will be two line as input.The first line is a number N(1&N&65536)telling you the number of coins on the desk.The&&&& second line is the result with N litters.The letter are "U","D",or &&&&"S","U" means the coin is on the right side. "D" means the coin is on &&&&the other side ."S" means standing on the desk.输出If &&&&test successeded,just output the possibility of the coin on the right &&&&side.If the test failed please output "Fail",If there is one or &&&&more"S",please output "Bingo"样例输入&&&&6&&&&UUUDDD&&&&样例输出&&&&1/2&&&&&&&&来源郑州大学校赛题目上传者张云聪&&&& &&&&#include&stdio.h&&&&&int divisor( int n, int m )&&&&{&&&&
if( n % m == 0 )&&&&&&&&
divisor( m, n % m );&&&&}&&&&int main( )&&&&{&&&&
int n, n1 = 0, n2 = 0, m1, m2;&&&&
char ch[65537];&&&&
bool stand =&&&&
scanf("%d", &n );&&&&
scanf("%s", ch );&&&&
for( int i = 0 ; i & i++ )&&&&
if( ch[i] == 'U' )&&&&
else if( ch[i] == 'D' )&&&&
else if( ch[i] == 'S' )&&&&
stand =&&&&
if( stand )&&&&
printf("Bingo\n");&&&&
else if( (1.0*n1/n) & (0.5+0.003) || (1.0*n1/n) & (0.5-0.003) )&&&&
printf("Fail\n");&&&&
printf("%d/%d\n", n1/divisor( n, n1 ), n/divisor( n, n1 ) );&&&&
return 0;&&&&}&&&&
&&&&&#include&cstdio&//最优程序&&&&int u,d;&&&&int gcd(int a,int b)&&&&{&&&&&& &if(a==0)&&&&&& &else return gcd(b%a,a);&&&&}&&&&int main()&&&&{&&&&&& &&&&&&& &&&&&&& &scanf("%d",&n);&&&&&& &getchar();&&&&&& &for(int i=0;i!=n;i++)&&&&&& &{&&&&&& &&& &c=getchar();&&&&&& &&& &if(c=='S') {puts("Bingo");return 0;}&&&&&& &&& &if(c == 'U') ++u;&&&&&& &&& &else ++d;&&&&&& &}&&&&&& &int g=gcd(u,u+d);&&&&&& &if((double)u/(u+d)-0.5&0.003 ||(double)u/(u+d)-0.5&-0.003) puts("Fail");&&&&&& &else printf("%d/%d",u/g,(u+d)/g);&&&&}&&&&&&& &&&&
&&&&206、&&&&矩形的个数&&&&时间限制:&&&&难度:1&&&&描述 在一个3*2的矩形中,可以找到6个1*1的矩形,4个2*1的矩形3个1*2的矩形,2个2*2的矩形,2个3*1的矩形和1个3*2的矩形,总共18个矩形。给出A,B,计算可以从中找到多少个矩形。输入本题有多组输入数据(&10000),你必须处理到EOF为止输入2个整数A,B(1&=A,B&=1000)输出输出找到的矩形数。 样例输入&&&&1 2&&&&3 2&&&&&&&&样例输出&&&&3&&&&18&&&&&&&&来源FOJ月赛-2007年3月上传者ACM_赵铭浩&&&& &&&&#include "stdio.h"&&&&int main(int argc, char const *argv[])&&&&{&&&& int a,b;&&&& while(scanf("%d%d",&a,&b)!=EOF)&&&& {&&&&
printf("%.0lf\n",(double)a*(a+1)*b*(b+1)/4);&&&& }&&&& return 0;&&&&}
&&&&&&&&&#include &stdio.h&//最优程序&&&&main(){float a,b;while(scanf("%f%f",&a,&b)+1)printf("%.0f\n",(a+1)*a*(b+1)*b/4);}&&&&&&& &&&&
&&&&216、&&&&A problem is easy&&&&时间限制:&&&&难度:3&&&&描述 One day Teddy met a old man in his dream , in that dream the man whose name was&RuLai& gave Teddy a problem :Given an N , can you calculate how many ways to write N as i * j + i + j (0 & i &= j) ?Teddy found the answer when N was less than 10&but if N get bigger , he found it was too difficult for him to solve.Well , you clever ACMers ,could you help little Teddy to solve this problem and let him have a good dream ?输入The first line contain a T(T &= 2000) . followed by T lines ,each line contain an integer N (0&=N &= 10^11).输出For each case, output the number of ways in one line样例输入&&&&2&&&&1&&&&3&&&&样例输出&&&&0&&&&1&&&&上传者苗栋栋&&&& &&&&#include&iostream&&&&&&&&&int main()&&&&{&&&&&&&&
cin&&n;&&&&
while(n--)&&&&
int a,count=0;&&&&
cin&&a;&&&&
for(int i=1; (i+1)*(i+1)&=(a+1); i++)&&&&
if((a+1)%(i+1)==0)&&&&
count++;&&&&
cout&&count&&&&&&
return 0;&&&&}&&&&&&&&&#include&cstring&&&&&#include&cstdio&&&&&#include&map&&&&&#include&string&&&&&#include&algorithm&&&&&#include&vector&&&&&#include&iostream&&&&&#include&cmath&&&&&&&&&#define CLR(arr,val) memset(arr,val,sizeof(arr))&&&&int main()&&&&{&&&&&& &int t,n,cnt=0;&&&&&& &//&&&&&& &&&&&&& &scanf("%d",&t);&&&&&& &while(t--)&&&&&& &{&&&&&& &//&& &scanf("%lld",&num);&&&&&& &&& &scanf("%d",&num);&&&&&& &&& &int nn=(int)(sqrt(num+1.0)+0.5);&&&&&& &&& &num++;&&&&&& &&& &cnt=0;&&&&&& &&& &for(int i=2;i&=i++)&&&&&& &&& &&& &if(num%i==0) cnt++;&&&&&& &&& &printf("%d\n",cnt);&&&&&& &}&&&&&& &&&&&}
&&&&217、&&&&a letter and a number&&&&时间限制:&&&&难度:1&&&&描述 输入On&&&& the first line, contains a number T(0&T&=10000).then T lines &&&&follow, each line is a case.each case contains a letter x and a number &&&&y(0&=y&1000).输出for each case, you should the result of y+f(x) on a line样例输入&&&&6&&&&R 1&&&&P 2&&&&G 3&&&&r 1&&&&p 2&&&&g 3&&&&样例输出&&&&19&&&&18&&&&10&&&&-17&&&&-14&&&&-4&&&&上传者苗栋栋&&&& &&&&#include "stdio.h"&&&&int main(int argc, char const *argv[])&&&&{&&&& &&&& //freopen("input.txt","r",stdin);&&&& scanf("%d",&n);&&&& while(n--)&&&& {&&&&
int b,c,d;&&&&
char ch=getchar();&&&&
scanf("%c%d",&a,&b);&&&&
if(a&='A'&&a&='Z')&&&&
d=c-64;&&&&
if(a&='a'&&a&='z')&&&&
d=96-c;&&&&
printf("%d\n",b+d);&&&& }&&&& return 0;&&&&}
&&&&&&&&&#include&stdio.h&//最优程序&&&&main()&&&&{&&&&&& &int x,n;&&&&&& &scanf("%d",&x);&&&&&& &while(x--)&&&&&& &{&&&&&& &&& &getchar();&&&&&& &&& &&&&&&& &&& &scanf("%c %d",&c,&n);&&&&&& &&&& if(c&=65&&c&=90) c=c-64;&&&&&& &&& &else c=0-(c-96);&&&&&& &&& &n=c+n;&&&&&& &&& &printf("%d\n",n);&&&&&& &&& &&&&&&& &}&&&&}&&&&&&&
&&&&241、&&&&字母统计&&&&时间限制:&&&&难度:1&&&&描述 现在给你一个由小写字母组成字符串,要你找出字符串中出现次数最多的字母,如果出现次数最多字母有多个那么输出最小的那个。输入第一行输入一个正整数T(0&T&25)随后T行输入一个字符串s,s长度小于1010。输出每组数据输出占一行,输出出现次数最多的字符;样例输入&&&&3&&&&abcd&&&&bbaa&&&&jsdhfjkshdfjksahdfjkhsajkf&&&&样例输出&&&&a&&&&a&&&&j&&&&&&&&来源[路过这]原创上传者路过这&&&& &&&&#include &stdio.h&&&&&#include "string.h"&&&&#include &iostream&&&&&&&&&int main(int argc, char const *argv[])&&&&{&&&&
int n,i,&&&&
char a[1011];&&&&
cin&&n;&&&&
getchar();&&&&
while(n--)&&&&
char b[1011]={0};&&&&
int fla=0,max=0;&&&&
cin&&a;&&&&
len=strlen(a);&&&&
for(i=0; i& i++)&&&&
b[a[i]-'a']++;&&&&
max=b[0];&&&&
for(i=0; i&26; i++)&&&&
if(b[i]&max)//||(b[i]==max&&a[i]-'a'&a[fla]-'a')&&&&
max=b[i];&&&&
fla=i;&&&&
cout&&(char)(fla+'a')&&&&&&
return 0;&&&&}&&&&
&&&&&#include&stdio.h&//最优程序&&&&#include&string.h&&&&&main()&&&&{&&&&&& &int x,i,max,q;&&&&&& &char a[1011];&&&&&& &scanf("%d",&x);&&&&&& &getchar();&&&&&& &while(x--)&&&&&& &{&&&&&& &&& &int s[26]={0};&&&&&& &&& &gets(a);&&&&&& &&& &for(i=strlen(a)-1;i&=0;i--)&&&&&& &&& &&& &s[a[i]-97]++;&&&&&& &&& &max=0;&&&&&& &&& &for(i=0;i&26;i++)&&&&&& &&& &&& &if(max&s[i]) max=s[i],q=i;&&&&&& &&& &printf("%c\n",q+97);&&&&&& &}&&&&&& &&&&&}&&&&&&&
&&&&242、&&&&计算球体积&&&&时间限制:&&&&难度:1&&&&描述 输入输入数据有多组,每组占一行,每行包括一个实数,表示球的半径。(0&R&100)输出输出对应的球的体积,对于每组输入数据,输出一行,计算结果四舍五入为整数Hint:PI=3.1415926样例输入&&&&1&&&&1.5&&&&样例输出&&&&4&&&&14&&&&来源Trinity上传者张洁烽&&&& &&&&#include&stdio.h&&&&&int main()&&&&{&&&&
double n,pi=3.1415926;&&&&
while(scanf("%lf",&n)==1)&&&&
printf("%.0lf\n",4*pi*n*n*n/3);&&&&
return 0;&&&&}&&&&
&&&&243、&&&&交换输出&&&&时间限制:&&&&难度:1&&&&描述 输入输入数据有多组,每组占一行,每行的开始是一个整数n,表示这个测试实例的数值的个数,跟着就是n个整数。n=0表示输入的结束,不做处理。输出对于每组输入数据,输出交换后的数列,每组输出占一行。样例输入&&&&4 2 1 3 4&&&&5 5 4 3 2 1&&&&0&&&&样例输出&&&&1 2 3 4&&&&1 4 3 2 5&&&&来源[张洁烽]原创上传者张洁烽&&&&#include&stdio.h&&&&&#include&iostream&&&&&&&&&int main() {&&&& int n, i, a[100], t,&&&& while (cin && n && n) {&&&&
j = 0;&&&&
for (i = 0; i & i++)&&&&
cin && a[i];&&&&
t = a[0];&&&&
for (i = 0; i & i++) {&&&&
if (a[0] & a[i]) {&&&&
a[0] = a[i];&&&&
a[j] =&&&&
for (i = 0; i & i++)&&&&
printf("%d ", a[i]);&&&&
printf("\n");&&&& }&&&& return 0;&&&&}&&&&&&&&&&&&&&#include&iostream&//最优程序&&&&#include&iterator&&&&&#include&algorithm&&&&&&&&&int data[110];&&&&int main()&&&&{&&&&&&&&&& &while(cin&&n && n)&&&&&& &{&&&&&& &&& &for(int i=0;i!=n;i++) cin&&data[i];&&&&&& &&& &iter_swap(data,min_element(data,data+n));&&&&&& &&& &copy(data,data+n,ostream_iterator&int&(cout," "));&&&&&& &&& &cout&&&&&&&& &}&&&&}&&&&&&&&&&&&&&&&&&&&&&& &&&&244、&&&&16进制的简单运算&&&&时间限制:&&&&难度:1&&&&描述 现在给你一个16进制的加减法的表达式,要求用8进制输出表达式的结果。输入第一行输入一个正整数T(0&T&100000)接下来有T行,每行输入一个字符串s(长度小于15)字符串中有两个数和一个加号或者一个减号,且表达式合法并且所有运算的数都小于31位输出每个表达式输出占一行,输出表达式8进制的结果。样例输入&&&&3&&&&29+4823&&&&18be+6784&&&&4ae1-3d6c&&&&样例输出&&&&44114&&&&100102&&&&6565&&&&来源[路过这]原创上传者路过这&&&&#include"stdio.h"&&&&int main() {&&&& int n, a,&&&& while (scanf("%d", &n) != EOF) {&&&&
while (n--) {&&&&
scanf("%x %x", &a, &b);&&&&
printf("%o\n", a + b);&&&&
}&&&& }&&&& return 0;&&&&}&&&&&&&&&#include&stdio.h&//最优程序&&&&int main()&&&&{&&&&&& &int T;&&&&&& &scanf("%d",&T);&&&&&& &while(T--)&&&&&& &{&&&&&& &&& &int a,b,d;&&&&&& &&& &&&&&&& &&& &scanf("%x%c%x",&a,&c,&b);&&&&&& &&& &if(c=='+') d=a+b;&&&&&& &&& &else d=a-b;&&&&&& &&& &if(d&=0)&&&&&& &&& &&& &printf("%o\n",d);&&&&&& &&& &else printf("-%o\n",-d);&&&&&& &}&&&&} &&&&& &&&&255、&&&&C小加 之 随机数&&&&时间限制:&&&&难度:1&&&&描述 ACM&&&&队的&C小加&同学想在学校中请一些同学一起做一项问卷调查,为了实验的客观性,他先用计算机生成了N个1到1000之间的随机整数&&&&(0&N&100),对于其中重复的数字,只保留一个,把其余相同的数去掉,不同的数对应着不同的学生的学号。然后再把这些数从小到大排序,按照排&&&&好的顺序去找同学做调查。请你协助&C小加&完成&去重&与&排序&的工作。输入第一行输入整数T(1&T&10)表示多少组测试数据,每组测试数据包括2行,第1行为1个正整数,表示所生成的随机数的个数:N(0&N&100)第2行有N个用空格隔开的正整数,为所产生的随机数。(随机数为题目给定的,不需要ACMer生成)输出输出也是2行,第1行为1个正整数M,表示不相同的随机数的个数。第2行为M个用空格隔开的正整数,为从小到大排好序的不相同的随机数。样例输入&&&&1&&&&10&&&&20 40 32 67 40 20 89 300 400 15&&&&样例输出&&&&8&&&&15 20 32 40 67 89 300 400&&&&来源RQNOJ上传者唐博&&&& &&&&#include&iostream&&&&&#include&algorithm&&&&&&&&&int main(int argc, char const *argv[])&&&&{&&&&&&&&
cin&&n;&&&&
while(n--)&&&&
int m,i,a[110],&&&&
count=0;&&&&
cin&&m;&&&&
for(i=0; i&m; i++)&&&&
cin&&a[i];&&&&
sort

我要回帖

更多关于 玩游戏自动退出 的文章

 

随机推荐