02 2013 档案

摘要:#include <stdio.h> #include <string.h>#define MAX 105 char set[MAX][MAX]; int main() { int i, j, count = 0, length_max = 0; for ( ;fgets(set[count], MAX, stdin); count++) { if ((i = strlen(set[count])) > length_max) length_max = i; } for (i = 0; i < length_max - 1; i++) { for (j = 阅读全文
posted @ 2013-02-28 19:11 L kill 阅读(176) 评论(0) 推荐(0) 编辑
摘要:#include<stdio.h>#include<math.h>int main(){long n,i,m,x,y; while (scanf("%d",&n),n) {m=sqrt(n); if (m*m==n){if (m%2==0){x=m;y=1;}else {x=1;y=m;}} else { if (m%2==1) {x=0;y=m+1; if (n-m*m<=m+1) x=x+n-m*m; else {x=m+1; n=n-m*m-m-1; y=y-n; } } else {x=m+1;y=0; if (n-m*m< 阅读全文
posted @ 2013-02-28 19:08 L kill 阅读(129) 评论(0) 推荐(0) 编辑
摘要:#include <stdio.h>int n,k,f[20][20]={0},a[20]={0},C;int main() { for(int i=0;i<=14;i++) { f[i][0]=1; for(int j=1;j<=i;j++) f[i][j]=f[i-1][j-1]+f[i-1][j]; } while(scanf("%d%d",&n,&k)==2) { for(int i=1;i<=k;i++) scanf("%d",&a[i]); C=1; for(int i=1,j=n;i&l 阅读全文
posted @ 2013-02-28 19:05 L kill 阅读(771) 评论(0) 推荐(0) 编辑
摘要:公式是网上查的,求图形 中各种型号的长方形,正方形的数量#include <stdio.h> int main() {long long s2,r2,s3,r3,s4,r4,N; while (scanf("%lld",&N)!=EOF) { s2=N*(N+1)*(2*N+1)/6; r2=(N+1)*N*N*(N+1)/4; s3=r2; r3=(N+1)*N*N*(N+1)*N*(N+1)/8; s4=(6*N*N*N*N*N+15*N*N*N*N+10*N*N*N-N)/30; r4=(N+1)*N*N*(N+1)*N*(N+1)*N*(N+1) 阅读全文
posted @ 2013-02-28 19:03 L kill 阅读(159) 评论(0) 推荐(0) 编辑
摘要:#include<stdio.h>int x;int y;int po[6][2]={0,-1,-1,0,-1,1,0,1,1,0,1,-1};void deal(int n,int age){int i;for(i=0;i<6;i++){ if(n<=age) { x+=n*po[i][0]; y+=n*po[i][1]; return ; } n-=age; x+=age*po[i][0]; y+=age*po[i][1];}}int main(){int n;while(scanf("%d",&n)!=EOF){ x=0; y=0; n 阅读全文
posted @ 2013-02-28 19:01 L kill 阅读(131) 评论(0) 推荐(0) 编辑
摘要:先把输入的第一个数按十进制转化为二地址,拆开相加得出来为b1, 第二个把原先的数按十六进制,然后转化为二进制,拆开求和得出b2#include<stdio.h>int main(){ int t,n,b1,b2,m; int a[10]={0,1,1,2,1,2,2,3,1,2};先把十六进制的转化为二进制,如3,0011.,得2 scanf("%d",&t); while(t--){ b1=b2=0; scanf("%d",&n); m=n; while(m!=0) {b1+=m%2; m=m/2;} while(n!=0) 阅读全文
posted @ 2013-02-28 18:59 L kill 阅读(170) 评论(0) 推荐(0) 编辑
摘要:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=996输出两个数之间差的绝对值#include<stdio.h>int main(){ long long a,b; while(scanf("%ld%ld",&a,&b)!=EOF){ if(a>b)printf("%ld\n",b-a);判断大小,决定输出哪个 else printf("%ld&q 阅读全文
posted @ 2013-02-28 18:57 L kill 阅读(90) 评论(0) 推荐(0) 编辑
摘要:#include <stdio.h>int main(){double a_1,a_0,a_n_1,sum,c;int i,t,n,k;while(scanf("%d",&t)==1){while(t--){scanf("%d%lf%lf",&n,&a_0,&a_n_1);sum=n*a_0+a_n_1;for(i=0;i<n;i++){scanf("%lf",&c);sum-=2*(n-i)*c;}printf("%.2lf\n",sum/(n+1));i 阅读全文
posted @ 2013-02-28 18:56 L kill 阅读(294) 评论(0) 推荐(0) 编辑
摘要:回到高中物理,公式2*v*t,输入t跟t,#include<stdio.h> int main() { int v,t; while(scanf("%d %d", &v,&t) != EOF) printf("%d\n", 2*v*t); return 0;} http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=12&page=show_problem&problem=1012 阅读全文
posted @ 2013-02-28 18:55 L kill 阅读(84) 评论(0) 推荐(0) 编辑
摘要:这题老师讲过,跟空瓶子一样#include <stdio.h>int main() { int n,k,t; while(scanf("%d%d",&n,&k)==2)等于2代表输入都成功 {t=n; while(t>=k) { n+=t/k; t=t%k+t/k; } printf("%d\n",n);}return 0;} http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& 阅读全文
posted @ 2013-02-28 18:54 L kill 阅读(121) 评论(0) 推荐(0) 编辑
摘要:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2493 判断输入坐标在哪个方位,建立坐标系,关键是与 坐标原点比较#include<stdio.h>int main(){ int h,z,t,a,b; while(scanf("%d",&t)!=EOF){ if(t==0)break; scanf("%d%d",&a,&b); while(t--){ s 阅读全文
posted @ 2013-02-28 18:53 L kill 阅读(119) 评论(0) 推荐(0) 编辑
摘要:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2113 判断两个数的大小,输出>或<或=#include<stdio.h>int main(){ int t; long a,b; scanf("%d",&t); while(t--){ scanf("%ld%ld",&a,&b); if(a>b)printf(">\n&q 阅读全文
posted @ 2013-02-28 18:52 L kill 阅读(150) 评论(0) 推荐(0) 编辑
摘要:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2899 t表示次数,换行表示一次,#include<stdio.h>int main(){ char b; int m=0,a[10000],i,t,max; scanf("%d",&t); while(t--){ m++; scanf("%d",&a[0]); max=a[0]; for(i=1;(b=getch 阅读全文
posted @ 2013-02-28 18:51 L kill 阅读(104) 评论(0) 推荐(0) 编辑
摘要:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2827 三个数中,选出中间那个,cmax我用来表示的#include<stdio.h>int main(){ int n,a,b,c,cmax,m=0; scanf("%d",&n); while(n--){ m++; scanf("%d%d%d",&a,&b,&c); if(a>b)if(a 阅读全文
posted @ 2013-02-28 18:50 L kill 阅读(174) 评论(0) 推荐(0) 编辑
摘要:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2864 玛丽奥跳高跳低的,输出跳高跟跳低的次数 定义两个变量统计。#include<stdio.h>int main(){ int n,t,h,l,a[50],i,m=0; scanf("%d",&n); while(n--){ h=l=0; scanf("%d",&t); scanf("%d" 阅读全文
posted @ 2013-02-28 18:48 L kill 阅读(97) 评论(0) 推荐(0) 编辑
摘要:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2307f(n) = 1+2+3+4+5+6+7+8+9+2 = 47 f(f(n)) = 4+7 = 11 f(f(f(n))) = 1+1 = 2一直重复做,直到是单位数#include<stdio.h>int main(){ long n,t,sum=0; while(scanf("%ld",&n)!=EOF){ if(n==0)brea 阅读全文
posted @ 2013-02-28 18:47 L kill 阅读(159) 评论(0) 推荐(0) 编辑
摘要:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1985不知道在讲什么,只是瞎蒙的,居然对了,求指教 啊#include <stdio.h> int main(){ int a,b,t; scanf("%d",&t); while(t--) { scanf("%d%d",&a,&b); printf("%d\n",(a/3)*(b/3) 阅读全文
posted @ 2013-02-28 18:45 L kill 阅读(93) 评论(0) 推荐(0) 编辑
摘要:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1753 給你這2個值,你能推出這2隊最後的得分是多少嗎? Input輸入的第一列有一個整數,代表以下有多少組測試資料。每組測試資料一列,有2個大於等於 0 的整數 s, d,s 代表比賽結束時2隊分數的總和, d 代表比賽結束時2隊分數差的絕對值。Output對每組測試資料輸出一列,包含2個整數代表比賽結束時這2隊的分數,分數大的在前。如果沒有這樣的分數,請輸出「 impossib 阅读全文
posted @ 2013-02-28 18:44 L kill 阅读(188) 评论(0) 推荐(0) 编辑
摘要:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1241 他输入的第一行包含一个正整数n(<20),测试用例的数量。每个测试案例开始行包含一个整数F(0<F<20),农民在测试用例的数量。这条线后面一个农民每行包含三个正整数,每个农家平方米大小的,动物的数量,他拥有和农民的环境友好的整数值表示。终止输入文件的末尾。在输入中没有整数大于100000或小于0。 ? 产量 对于每个测试用例输出一行,包含一个整数,持有的 阅读全文
posted @ 2013-02-28 18:43 L kill 阅读(188) 评论(0) 推荐(0) 编辑
摘要:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=435 判断句子中有几个词; 句子中除了字母,标点,空格都是判断标志, 有时候会出现很多的标点,所以要设置一个变量来判断,如n#include<stdio.h>#include<string.h>int main(){ char s[1000]; int i,num,t,n; while(gets(s)!=NULL){ num=0; n=0; t=strlen 阅读全文
posted @ 2013-02-28 18:41 L kill 阅读(121) 评论(0) 推荐(0) 编辑
摘要:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=208 自己看题吧,把'替换为’#include <stdio.h>#include <string.h>#define N = 1000;int main(){int i,j,cnt=0; char src[N],dst[N]; while(gets(src)){for(i=j=0;i<strlen(src);i++){ if(src[i]!= 阅读全文
posted @ 2013-02-28 18:38 L kill 阅读(198) 评论(0) 推荐(0) 编辑
摘要:地址:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=36 如果你是奇数,n=3n+1;偶数,n=n/2; 硬推;#include<stdio.h>int arr[100001];int main(){ int a,b;int i; arr[1]=1; arr[2]=2; for(i=3;i<10001;i++) { long long temp=i; int cnt=0; while(temp!=1) { if 阅读全文
posted @ 2013-02-28 18:35 L kill 阅读(135) 评论(0) 推荐(0) 编辑