ZOJ
andyyang0212
这个作者很懒,什么都没留下…
展开
-
zoj 2417 Lowest Bit
#include#includeint main(){ int n,count,flag; while(scanf("%d",&n)&&n){ count = 0; flag = 0; while(n){ flag = n % 2; if(flag) break; count++; n /= 2; } printf("%d\n",(int)pow原创 2014-09-04 12:03:15 · 335 阅读 · 0 评论 -
zoj 1240 IBM Minus One
#include#includeint main(){ struct string{ char ch[80]; struct string *next; } *p,*head,*tail; int n,i,num; scanf("%d",&n); num = n; head = tail = NULL; while(n--){ p = (struct string原创 2014-08-14 16:01:44 · 309 阅读 · 0 评论 -
zoj 1242 Carbon Dating
//要点 log()自然对数,#include#includeint main(){ int a,b; int year,n,m,i; i = 1; while(1){ scanf("%d%d",&a,&b); if(a == 0&&b == 0) break; else{ year = -5730*log10(b*1.0/(a*810))/log10(2);原创 2014-08-14 20:01:42 · 408 阅读 · 0 评论 -
zoj 1251 Box of Bricks
#include#includeint main(){ int *p,n,average,count,i,sum,m; m = 1; while(1){ scanf("%d",&n); if(n == 0) break; p = (int *)malloc(n*sizeof(int)); for(i = 0,sum原创 2014-08-14 20:30:04 · 354 阅读 · 0 评论 -
zoj 2099 Frame Polygonal Line
#includeint main(){ long a[2][2],x,y; while(scanf("%ld%ld",&x,&y)&&(x||y)){ a[0][0] = x; a[0][1] = x; a[1][0] = y; a[1][1] = y; while(scanf("%ld%ld",&x,&y)&&(x||y)){ if(x>a[0][1]) a[0原创 2014-09-02 21:16:36 · 341 阅读 · 0 评论 -
zoj 1915 Above Average
#include#includeint main(){ int times,n,*p,i,count; double aver; scanf("%d",×); while(times--){ scanf("%d",&n); p = (int *)malloc(n*sizeof(int)); aver = 0; for(i = 0;i<n;i++){ scanf(原创 2014-09-02 14:59:01 · 323 阅读 · 0 评论 -
zoj 1796 Euchre Results
#includeint main(){ int a[3][2]; int i,sum,win,lose; while(1){ scanf("%d%d",&a[0][0],&a[0][1]); if(a[0][0]==0&&a[0][1]==0) break; win = a[0][0]; lose = a[0][1]; for(i = 1;i<3;i++){原创 2014-09-01 16:52:10 · 353 阅读 · 0 评论 -
zoj 1337 Pi
#include#include#includeint prime(int a,int b){ int i; for(i = 2;i<=b;i++) if(a % i == 0 && b % i == 0) return 0; return 1;}int main(){ int n,i,j,sum; double pi; int *p; while(scanf原创 2014-08-16 16:11:20 · 359 阅读 · 0 评论 -
zoj 2321
#includeint main(){ int b,c,n,flag; double a; while(scanf("%lf%d%d",&a,&b,&c)&&b){ flag = 0; if(a=150&&c>=200) {printf("Wide Receiver"); flag = 1; } if(a=300&&c>=500){ if(flag)原创 2014-09-03 22:47:57 · 339 阅读 · 0 评论 -
zoj 2108 Elevator
//#includeint main(){ int n,sec,flr,now; while(scanf("%d",&n)&&n){ sec = 0; now = 0; while(n--){ scanf("%d",&flr); if(flr - now > 0) sec += (flr - now)*6 + 5; if(flr - now < 0) sec原创 2014-09-03 11:07:25 · 451 阅读 · 0 评论 -
zoj 1879 Jolly Jumpers
//要遍历1到n-1#include#include#include#includeint main(){ int n,x,y,flag,num,*p,i; while(scanf("%d",&n)!=EOF){ flag = 0; p = (int *)malloc(sizeof(int)*n); memset(p,0,n*sizeof(int)); num原创 2014-09-01 20:02:34 · 304 阅读 · 0 评论 -
ZOJ 1365
//字符 #include#include#includeint main(){ double mile,sum; char code,city1[80],city2[80]; while(1){ sum = 0; while(scanf("%s",city1)){ if(strcmp(city1,"#") == 0) return 0; if(strcmp原创 2014-08-17 16:40:05 · 386 阅读 · 0 评论 -
zoj 1383 Binary Numbers
#includeint main(){ int time,n,i; scanf("%d",&time); while(time--){ scanf("%d",&n); i = 0; while(n != 0){ if(n % 2 ) { printf("%d",i); if(n / 2) printf(" "); else p原创 2014-08-20 08:33:02 · 298 阅读 · 0 评论 -
zoj 1402 Magnificent Meatballs
#include#includeint main(){ int n,*p,i,sum; while(1){ scanf("%d",&n); if(n == 0) break; p = (int *)malloc(n*sizeof(int)); sum = 0; for(i = 0;i<n;i++){ scanf("%d",&p[i]);原创 2014-08-20 09:45:27 · 344 阅读 · 0 评论 -
zoj 1331 Perfect Cubes
#include int main(){ long a,b,c,d; for(a = 4;a<= 200;a++) for (b = 2;b<= 199;b++) for(c = b+1;c<=199;c++) for(d = c+1;d<=199;d++) if(a*a*a < b*b*b + c*c*c + d*d*d) break; else原创 2014-08-16 15:18:33 · 319 阅读 · 0 评论 -
zoj 2172 Symmetric Order
#include#includeint main(){ int i,j,flag,n,times,num; char str[15][26]; char ch[26]; times = 1; while(scanf("%d",&n)&&n){ flag = 0; i = 0; j = n - 1; num = n; while(n--){ scanf("%原创 2014-09-03 17:25:48 · 353 阅读 · 0 评论 -
zoj 1730 Crazy Tea Party
//可以看成 #includeint main(){ int n,time,i,num; long count; scanf("%d",&time); while(time--){ scanf("%d",&n); i = 1; num = n; count = 0; while(n > 3){ count = count + (i < (n - 2) ? i原创 2014-09-01 10:44:40 · 345 阅读 · 0 评论 -
zoj 1494 Climbing Worm
#includeint main(){ int n,d,u,min,mile; while(1){ scanf("%d%d%d",&n,&u,&d); if(n== 0) break; mile = 0; min = 0; while(n>mile){ mile += u; min++; if(mile>=n) break; else{原创 2014-08-20 10:49:04 · 368 阅读 · 0 评论 -
zoj1205Martian Addition
以20进制相加#include#include#includeint main(){ int op1[100]; int op2[100]; char result[102]; char str[101]; int carriage; int i,len1,len2,a,b,sum,j,k; while(scanf("%s",str)!=EOF) { len1原创 2014-08-11 19:55:54 · 413 阅读 · 0 评论 -
ZOJ1149
#include#include#includeint main(){ int n,i,*p; double x,y,distance,r; scanf("%d",&n); p = (int*)malloc(sizeof(int)*n); for(i = 0;i<n;i++) { scanf("%lf %lf",&x,&y); dis原创 2014-08-11 15:23:53 · 354 阅读 · 0 评论 -
zoj 2376 Ants
#include#includeint main(){ int n,len,num,ant,lf,rt,max; double mid,md; scanf("%d",&n); while(n--){ scanf("%d%d",&len,&num); mid = len*1.0/2; md = len; lf = len; rt = 0; while(num--)原创 2014-09-03 23:01:07 · 401 阅读 · 0 评论 -
1622 Switch
// #includeint main(){ int n,count1,light,flag,i,count2; while(scanf("%d",&n) != EOF){ count1 = 0; count2 = 0; i = 1; while(n--){ scanf("%d",&light); if(light == 0 && i % 2||light =原创 2014-09-01 09:19:50 · 306 阅读 · 0 评论 -
ZOJ 1394 Polar Expoler
#include#includeint main(){ int x,y,z; double mile; char str[20]; while(10){ scanf("%s",str); if(strcmp(str,"ENDOFINPUT") == 0) break; scanf("%d%d%d",&x,&y,&z); scanf("%s",str); z = z原创 2014-08-20 09:17:48 · 333 阅读 · 0 评论 -
zoj 2433 Highways
//因为每个点只能是一条新路的起点#include#include#includeint main(){ int times,n,before,len,i,count,j,temp,q0,q1,q2,m0,m1,m2; int *p; scanf("%d",×); while(times--){ scanf("%d",&n); p = (int *)malloc(sizeof原创 2014-09-05 23:05:32 · 514 阅读 · 0 评论 -
zoj 2001 Adding Reversed Numbers
#includeint reserve(int a){ int result = 0; while(a){ result = result*10 + a % 10; a /= 10; } return result;}int main(){ int times,a,b; scanf("%d",×); while(times--){ scanf("%d%d",&a,原创 2014-09-02 15:46:17 · 334 阅读 · 0 评论 -
zoj 1889 Ones
#include#include#includeint main(){ int i,n; long num; while(scanf("%d",&n) != EOF){ i = 1; num = 1; while(num % n != 0){ i++; num = (num % n)*10 + 1; } printf("%d\n",i); } re原创 2014-09-01 20:26:18 · 287 阅读 · 0 评论 -
zoj 1904 Beavergnaw
#include#include#define PI 3.1415926int main(){ int d,v; while(scanf("%d%d",&d,&v) &&d&&v){ printf("%.3lf\n",pow(d*d*d- 6*v/PI,1.0/3.0)); } return 0;}盗图一张原创 2014-09-02 11:24:14 · 405 阅读 · 0 评论 -
zoj 1813 Biker's Trip Odometer
#includeint main(){ int i; long rev; double sec,dia,dis; i = 1; while(1){ scanf("%lf%ld%lf",&dia,&rev,&sec); if(rev == 0) break; dis = dia *rev * 3.1415927 /(12 *5280); sec = sec /(60*原创 2014-09-01 17:11:04 · 311 阅读 · 0 评论 -
zoj 1760 Doubles
#includeint main(){ int num[15]; int i,n,dou,j; while(1){ scanf("%d",&n); if(n == -1) break; i = 0; num[i] = n; dou = 0; while(scanf("%d",&n)&&n){ for(j = 0;j<=i;j++) if(n == 2原创 2014-09-01 16:24:33 · 270 阅读 · 0 评论 -
zoj 1382 A Sample Task
#includeint main(){ int n,time,p,o,i; scanf("%d",&time); while(time--){ o = 0; scanf("%d",&n); while(n%2==0){ o++; n = n /2; } printf("%d %d\n",n,o); } return 0;}原创 2014-08-20 08:21:21 · 382 阅读 · 0 评论 -
zoj1216deck
//关键点推导出公式,啊【】#include#include#include int main(){ double card(int n); int n; struct num { double result; int order; struct num *next; } *p,*head,*tail; head = tail = NULL; while(sc原创 2014-08-14 15:25:54 · 342 阅读 · 0 评论 -
zoj 2176 Speed Limit
#includeint main(){ int sp,n,tm,mile,tmp; while(scanf("%d",&n)&&n>=0){ mile = 0; tmp = 0; while(n--){ scanf("%d%d",&sp,&tm); mile += sp*(tm - tmp); tmp = tm; } printf("%d miles\原创 2014-09-03 20:27:20 · 394 阅读 · 0 评论 -
zoj 1350 The Drunk Jailer
#include#includeint main(){ int time,n,i,j,sum; int *p; scanf("%d",&time); while(time--){ scanf("%d",&n); p = (int *)malloc(sizeof(int)*n); for(i = 0;i<n;i++) p[i] =原创 2014-08-17 15:18:27 · 323 阅读 · 0 评论 -
ZOJ1101
#includeint main(){int a,b; while(scanf("%d %d",&a,&b) !=EOF) { printf("%d\n",a + b); }return 0;}原创 2014-08-11 15:21:22 · 425 阅读 · 0 评论 -
ZOJ1137
//a、b如果有一个为偶数则可以不走斜线,若同时为奇则必走一斜线#include#includeint main(){ int n,i,a,b; double *p; scanf("%d",&n); p = (double *)malloc(sizeof(double)*n); for(i = 0;i<n;i++) { scanf("%d %d",&a,&b);原创 2014-08-11 15:22:48 · 459 阅读 · 0 评论 -
ZOJ Basically Speaking
#include#includeint main(){ char str[8]; int before,after,result,i,num; while(scanf("%s%d%d",str,&before,&after) != EOF) { result = 0; for(i = 0;str[i]!='\0';i++){ if(str[i]>='0原创 2014-08-16 15:45:15 · 322 阅读 · 0 评论 -
zoj 2405 Specialized Four-Digit Numbers
#includeint jud(int n,int d){ int sum; sum = 0; while(n){ sum += n % d; n /= d; }return sum;}int main(){ int i; for(i = 2992;i<10000;i++) if(jud(i,10)==jud(i,12)&&jud(i,10) == jud(i,16原创 2014-09-04 11:58:27 · 563 阅读 · 0 评论 -
zoj 2109 简单贪心背包
用qsort过不了,sort就过了不知道为什么#include#include #include#include using namespace std;struct fm{ int j,f; double jperf;} cat[1010];bool cmp( struct fm a,struct fm b ) { return a.jperf>b.jpe原创 2014-12-30 19:03:52 · 356 阅读 · 0 评论