上一页 1 ··· 3 4 5 6 7 8 9 下一页
摘要: #include<stdio.h>long long a,b;long long up(long long a,long long b){ long long t; if(a==0) return b; while(b!=0) { t=b;b=a%b;a=t; }//求最大公约数; return a;}int main(){ while(scanf("%lld%lld",&a,&b)!=EOF) { if(a==0&&b==0) break; printf("%lld\n",a*b/up(a,b)/up(a,b 阅读全文
posted @ 2012-08-29 17:28 尔滨之夏 阅读(317) 评论(0) 推荐(0) 编辑
摘要: #include<stdio.h>int main(){ long int i,n; long int s1,s2,s; while(scanf("%ld",&n)!=EOF) { s1=0;s2=0;s=0; if(n%2==0) {s1=n/2%2011;s2=(n+1)%2011;}// (a+b)%c与(a%c+b%c)%c相等,乘时也一样, else {s1=(n+1)/2%2011;s2=n%2011;} s=(s1*s2)%2011; printf("%ld\n",s); } return 0;} 阅读全文
posted @ 2012-08-28 21:56 尔滨之夏 阅读(254) 评论(0) 推荐(0) 编辑
摘要: #include<stdio.h>int main(){int n,i,m,l,k,p,j,t,a[1000]; scanf("%d",&t);for(i=0;i<t;i++){ scanf("%d%d",&n,&m); p=0;for(k=0;k<n;k++){ l=0;for(j=0;j<m;j++) scanf("%d",&a[j]);for(j=0;j<m;j++)if(a[j]>80) l++;if(l>3) p++;} printf(" 阅读全文
posted @ 2012-08-27 22:22 尔滨之夏 阅读(284) 评论(0) 推荐(0) 编辑
摘要: #include<stdio.h>#include<string.h>#define max(a,b)((a)>(b))?(a):(b)int a[101][101],d[101][101];int n;int dp(int i,int j){ if(d[i][j]>=0)return d[i][j]; return d[i][j]=a[i][j]+(i==n-1?0:max(dp(i+1,j),dp(i+1,j+1)));}int main(){ int i,j; while(scanf("%d",&n)!=EOF) { for 阅读全文
posted @ 2012-08-23 18:23 尔滨之夏 阅读(2858) 评论(0) 推荐(0) 编辑
摘要: #include<stdio.h>int main(){ int x_y(int x,int y); int i,n,a[1111],s; while(scanf("%d",&n)!=EOF) { for(i=0;i<n;i++) scanf("%d",&a[i]); if(n==1)printf("%d\n",a[0]); else { s=x_y(a[0],a[1]); for(i=1;i<n;i++) s=x_y(s,a[i]); } printf("%d\n",s); 阅读全文
posted @ 2012-06-10 16:16 尔滨之夏 阅读(7377) 评论(0) 推荐(0) 编辑
摘要: 将m赋值为a[n]然后对新数列用快排排序,在输出。#include<stdio.h>#include<stdlib.h>int cmp(const void*p1,const void*p2){ return *(int*)p1-*(int*)p2;}int main(){ int n,m,i,a[111]; while(scanf("%d%d",&n,&m)!=EOF) { if(m==0&&n==0)break; a[n]=0; for(i=0;i<n;i++) scanf("%d",&a 阅读全文
posted @ 2012-06-05 20:00 尔滨之夏 阅读(25779) 评论(0) 推荐(0) 编辑
摘要: #include<stdio.h>int main(){ int n,i,t,w,j[102],k; while(scanf("%d",&n)!=EOF) { if(n==0)break; for(i=0;i<n;i++) scanf("%d",&j[i]); w=j[0]; for(i=0;i<n;i++) { if(j[i]<=w) k=i; w=j[k]; } if(w!=j[0]) {t=j[k];j[k]=j[0];j[0]=t;} for(i=0;i<n;i++) if(i==0) prin 阅读全文
posted @ 2012-06-05 07:31 尔滨之夏 阅读(15413) 评论(0) 推荐(0) 编辑
摘要: #include<stdio.h>int main(){ int m,n,i,line[104],s,j,h; int aver1,aver2; while(scanf("%d%d",&n,&m)!=EOF) { line[0]=2; for(i=1;i<n;i++) line[i]=line[i-1]+2; h=n%m; for(j=0;j<n/m;j++) { s=0; for(i=j*m;i<(j+1)*m;i++) s=line[i]+s; aver1=s/m; if(j==0) printf("%d" 阅读全文
posted @ 2012-06-04 21:17 尔滨之夏 阅读(16878) 评论(0) 推荐(0) 编辑
摘要: #include<stdio.h>#include<stdlib.h>int cmp(const void*p1,const void*p2){ return *(int*)p1-*(int*)p2;}int main(){ int n,score[105],i; double s,aver; while(scanf("%d",&n)!=EOF) { s=0; for(i=0;i<n;i++) scanf("%d",&score[i]); qsort(score,n,sizeof(score[0]),cmp) 阅读全文
posted @ 2012-06-04 17:10 尔滨之夏 阅读(18000) 评论(0) 推荐(0) 编辑
摘要: #include<stdio.h>int main(){ struct student { int num; char name[20]; float score; }student1,student2; scanf("%d%s%f",&student1.num,student1.name,&student1.score); scanf("%d%s%f",&student2.num,student2.name,&student2.score); if(student1.score>student2.sco 阅读全文
posted @ 2012-05-30 14:59 尔滨之夏 阅读(166) 评论(0) 推荐(0) 编辑
上一页 1 ··· 3 4 5 6 7 8 9 下一页