数论 READ MORE →
HDOJ1038:Biker’s Trip Odometer——数学题
Problem Description
Most bicycle speedometers work by using a Hall Effect sensor fastened to the front fork of the bicycle. A magnet is attached to one of the spokes on the front wheel so that it will line up with the Hall Effect switch once per revolution of the wheel. The speedometer monitors the sensor to count wheel revolutions. If the diameter of the wheel is known, the distance traveled can be easily be calculated if you know how many revolutions the wheel has made. In addition, if the time it takes to complete the revolutions is known, the average speed can also be calculated.
For this problem, you will write a program to determine the total distance traveled (in miles) and the average speed (in Miles Per Hour) given the wheel diameter, the number of revolutions and the total time of the trip. You can assume that the front wheel never leaves the ground, and there is no slipping or skidding.
Input
Input consists of multiple datasets, one per line, of the form:
diameter revolutions time
The diameter is expressed in inches as a floating point value. The revolutions is an integer value. The time is expressed in seconds as a floating point value. Input ends when the value of revolutions is 0 (zero).
Output
For each data set, print:
Trip #N: distance MPH
Of course N should be replaced by the data set number, distance by the total distance in miles (accurate to 2 decimal places) and MPH by the speed in miles per hour (accurate to 2 decimal places). Your program should not generate any output for the ending case when revolutions is 0.
Constants
For p use the value: 3.1415927.
There are 5280 feet in a mile.
There are 12 inches in a foot.
There are 60 minutes in an hour.
There are 60 seconds in a minute.
There are 201.168 meters in a furlong.
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
一道数学题。简单水过。注意格式即可。
代码:
#include #define Pi 3.1415927 int main() { int n,c=0; double t,d,v,s; while(scanf("%lf%d%lf",&d,&n,&t)!=EOF && n!=0) { s=n*Pi*d/12/5280; v=s/(t/60/60); printf("Trip #%d: %.2lf %.2lf\n",++c,s,v); } return 0; }
HDOJ1037:Keep on Truckin'
不开心?睡一觉冷静冷静……
READ MORE →
HDOJ1064:Financial Management
不开心?做几道水题冷静冷静……
READ MORE →
HDOJ2070:Fibbonacci Number——一道水题
不开心?写会儿代码冷静冷静……
READ MORE →
HDOJ1108:最小公倍数
最小公倍数
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 33998 Accepted Submission(s): 19029
Problem Description
给定两个正整数,计算这两个数的最小公倍数。
Input
输入包含多组测试数据,每组只有一行,包括两个不大于1000的正整数.
Output
对于每个测试用例,给出这两个数的最小公倍数,每个实例输出一行。
Sample Input
10 14
Sample Output
70
求最小公倍数的问题,辗转相除法解决。
代码:
#include int main() { int a,b,ai,bi,temp; while (scanf ("%d %d",&a,&b) != EOF) { ai = a; bi = b; while (bi != 0) { temp = bi; bi = ai % bi; ai = temp; } printf ("%dn",a*b/ai); } return 0; }
HDOJ2071:Max Num
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 13674 Accepted Submission(s): 8661
Problem Description
There are some students in a class, Can you help teacher find the highest student .
Input
There are some cases. The first line contains an integer t, indicate the cases; Each case have an integer n ( 1 ≤ n ≤ 100 ) , followed n students’ height.
Output
For each case output the highest height, the height to two decimal plases;
Sample Input
2
3 170.00 165.00 180.00
4 165.00 182.00 172.00 160.00
Sample Output
180.00
182.00
水题,放上代码:
#include int main() { int n,ni,j,ji; double num[100],ans; scanf("%d",&n); for(ni=0;nians) { ans=num[ji]; } } printf("%.2lfn",ans); } return 0; }
其实还是有运气的成分在里面,因为样例中的数据可能都是精确到小数点后两位,所以可以通过.2lf直接输出.还没有想到可以直接根据输入数据给出输出精度的方法.
HDOJ2107:Founding of HDU
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 6500 Accepted Submission(s): 4403
Problem Description
经过慎重的考虑,XHD,8600, LL,Linle以及RPG等ACM队员集体退役,甚至正在酝酿退学。
为什么?要考研?那也不用退学呀…
当然不是!真正的原因是他们想提前创业,想合伙成立一家公司,据说公司的名称都想好了,为了感谢多年的ACM集训队队长XHD,公司就叫海东集团(HaiDong Union),简称HDU.(对于这个公司名称,几个人私下里开玩笑说,外面的人看到HDU,可别以为是”胡捣集团”,呵呵)
公司成立了,谁来做老大呢?这对于合伙的公司可是一个难题。好在几位同学经过几年的ACM训练,思维非常活跃,马上想到推选AC战斗力最强的一位来做老总。
现在的问题就是,假设每人的AC战斗力是一个已知的整数,请编程输出最后选出的老总的AC战斗力。
Input
输入包含多组测试数据,每组数据占2行,首先一行是一个整数n(n<100),表示创立公司的人数,然后一行是n个32位整数,表示n个人的AC战斗力,n为0的时候结束输入。
Output
对于每个测试实例,请输出老总的AC战斗力,每个实例的输出占一行。
Sample Input
3
1 2 3
0
Sample Output
3
谁将是HDU的老总呢?
欲知后事如何,且听下回分解——
#include int main() { int n,ni,a[100],out; while(scanf("%d",&n)&&(n!=0)) { for(ni=0;ni<n;ni++) { scanf("%d",&a[ni]); if(ni==0) { out=a[ni]; } if(a[ni]>out) { out=a[ni]; } } printf("%dn",out); } return 0; }
苍茫的水题,( ̄o ̄) . z Z
HDOJ1976:Software Version
Problem Description
相信大家一定有过在网上下载软件而碰到多个不同版本的情况。
一般来说,软件的版本号由三个部分组成,主版本号(Major Version Number),子版本号(Minor Version Number)和修订号(Revision_Number)。当软件进行了重大的修改时,主版本号加一;当软件在原有基础上增加部分功能时,主版本号不变,子版本号加一;当软件仅仅修正了部分bug时,主版本号和子版本号都不变,修正号加一。
在我们比较软件的两个版本的新旧时,都是先比较主版本号,当主版本号相同时再比较子版本号,前两者都相同的情况下再比较修正号。版本号越大的软件越新。
现在,Lele 在载软件的时候碰到了两个版本,请你告诉他哪个版本更新一些。
Input
输入的第一行有一个整数T,代表有T组测试。接下来有T组测试。
每组测试分两行,第一行有三个整数代表第一个软件版本的主版本号,子版本号和修订号。第二行也有三个整数代表第二个软件版本的主版本号,子版本号和修订号。
数据中出现的整数都在[0,1000]范围之内。
Output
对于每组测试,如果第一个软件的版本新点,请输出”First”,如果第二个软件的版本新点,请输出”Second”,否则输出”Same”。
Sample Input
3
1 1 0
1 1 1
1 1 1
1 1 0
1 1 1
1 1 1
Sample Output
Second
First
Same
#include #include int main() { int n, ni, a[3], b[3]; scanf("%d", &n); for (ni = 0; ni<n; ni++) { memset(a, 0, sizeof(a)); memset(b, 0, sizeof(b)); scanf("%d%d%d", &a[0], &a[1], &a[2]); scanf("%d%d%d", &b[0], &b[1], &b[2]); if (a[0]>b[0]) printf("Firstn"); else { if (a[0] < b[0]) printf("Secondn"); else { if (a[1]>b[1]) printf("Firstn"); else { if (a[1] < b[1]) printf("Secondn"); else { if (a[2]>b[2]) printf("Firstn"); else { if (a[2] < b[2]) printf("Secondn"); else printf("Samen"); } } } } } } return 0; }
水题一次过,没什么好说的……
HDOJ2304:Electrical Outlets
Problem Description
Roy has just moved into a new apartment. Well, actually the apartment itself is not very new, even dating back to the days before people had electricity in their houses. Because of this, Roy’s apartment has only one single wall outlet, so Roy can only power one of his electrical appliances at a time.
Roy likes to watch TV as he works on his computer, and to listen to his HiFi system (on high volume) while he vacuums, so using just the single outlet is not an option. Actually, he wants to have all his appliances connected to a powered outlet, all the time. The answer, of course, is power strips, and Roy has some old ones that he used in his old apartment. However, that apartment had many more wall outlets, so he is not sure whether his power strips will provide him with enough outlets now.
Your task is to help Roy compute how many appliances he can provide with electricity, given a set of power strips. Note that without any power strips, Roy can power one single appliance through the wall outlet. Also, remember that a power strip has to be powered itself to be of any use.
Input
Input will start with a single integer 1 <= N <= 20, indicating the number of test cases to follow. Then follow N lines, each describing a test case. Each test case starts with an integer 1 <= K <= 10, indicating the number of power strips in the test case. Then follow, on the same line, K integers separated by single spaces, O1 O2 . . . OK, where 2 <= Oi <= 10, indicating the number of outlets in each power strip.
Output
Output one line per test case, with the maximum number of appliances that can be powered.
Sample Input
3
3 2 3 4
10 4 4 4 4 4 4 4 4 4 4
4 10 10 10 10
Sample Output
7
31
37
欢乐地一次过,60AC达成~(貌似有点晚),,ԾㅂԾ,,
#include int main() { int n,ni,j,ji,a[20],sum; scanf("%d",&n); while(n--) { scanf("%d",&j); sum=0; for(ji=0;ji