http://acm.hdu.edu.cn/game/entry/problem/list.php?chapterid=1§ionid=2
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;
}