码迷,mamicode.com
首页 > 其他好文 > 详细

杭电OJ(HDU)-ACM Steps-Chapter Two-《Biker's Trip Odometer》《Climbing Worm》《hide handkerchief》《Nasty Hac》

时间:2014-06-07 11:39:31      阅读:315      评论:0      收藏:0      [点我收藏+]

标签:杭电   acm   c   hdu   

1.2.1 Biker's Trip Odometer 
#include<stdio.h>
#include<math.h>
const double PI=acos(-1.0);
/*
计算题,根据公式做就行,PI*d*r/(12*5280);res1/t*3600;
Sample Input
26 1000 5
27.25 873234 3000
26 0 1000

Sample Output
Trip #1: 1.29 928.20
Trip #2: 1179.86 1415.84 
*/
int main()
{
    double d;
    int r;
    double t;
    int iCase=0;
    while(scanf("%lf%d%lf",&d,&r,&t),r)
    {
        iCase++;
        double res1=PI*d*r/(12*5280);
        double res2=res1/t*3600;
        printf("Trip #%d: %.2lf %.2lf\n",iCase,res1,res2);
    }    
    return 0;
}  

1.2.2 Climbing Worm
#include<stdio.h>
#include<math.h>

/*
Sample Input
10 2 1
20 3 1
0 0 0
 
总长为n,上升一秒走u,休息一秒下降d.相当于每两秒走(u-d);先n-u,得到过了多少个u-d后超过n-u;

Sample Output
17
19 
*/
int main()
{
    int n=1,u=1,d=1;
    while(scanf("%d %d %d",&n,&u,&d),n)
    {
		int t=(n-u)/(u-d);        
		if(t*(u-d)<(n-u)) 
			t++;        
		t*=2;        
		t++;        
		printf("%d\n",t);
    }    
    return 0;
}    

1.2.3 hide handkerchief
#include<stdio.h>
/*
丢手绢,用约瑟夫即可解决或者/辗转相除
3 2
-1 -1
*/
int main()
{
	int N,M,a;
	while(scanf("%d%d",&N,&M)==2)
	{
		if(N==-1&&M==-1)
			break;
		while(M!=0&&M!=1)
		{
			a=N%M;
			N=M;
			M=a;
		}
		printf("%s\n",M? "YES":"POOR Haha");
	}
	return 0;
}

1.2.4 Nasty Hacks 
#include<stdio.h>
/*
题意:e-c 跟r比较。
3
0 100 70
100 130 30
-100 -70 40
*/
int main()
{
	int r,e,c;
	int t;
	while(scanf("%d",&t)!=EOF)
	{
		while(t--)
		{
			scanf("%d%d%d",&r,&e,&c);
			if(r>(e-c))printf("do not advertise\n");  
			else if(r<(e-c))printf("advertise\n");  
			else printf("does not matter\n");  
		}
	}
	return 0;
}


 

杭电OJ(HDU)-ACM Steps-Chapter Two-《Biker's Trip Odometer》《Climbing Worm》《hide handkerchief》《Nasty Hac》,布布扣,bubuko.com

杭电OJ(HDU)-ACM Steps-Chapter Two-《Biker's Trip Odometer》《Climbing Worm》《hide handkerchief》《Nasty Hac》

标签:杭电   acm   c   hdu   

原文地址:http://blog.csdn.net/caisini_vc/article/details/28446079

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!