简单计算题三.ppt
《简单计算题三.ppt》由会员分享,可在线阅读,更多相关《简单计算题三.ppt(41页珍藏版)》请在三一文库上搜索。
1、第三讲,简单计算题(二),ACM算法与程序设计,初赛完成情况统计,通过4题:Team280110 通过3题:8311,Wzlxdzjy,xygy8860 通过2题:Supermokey369,zhlean,2804302029,clstone, wulidianzixueyuan 通过1题: w180285,Taozle123,JAG 未过题: zhengguifu,wanglikai91,luojiangbo, fuhang8902317,Ants Run!,Description Professor Yang likes to play with ants when he is free.
2、 What? Are you asking why he plays with ants instead of others? Ah, because ant is the only non-plant living thing which can be found in Qingshuihe Campus of UESTC apart from human beings. This time, Professor Yang caught several ants after finishing his lecture for freshmen. At the beginning of the
3、 game, he puts N ants around a plate and numbers them in clockwise order. The ants are so obedient that they run clockwise under the guide of Professor Yang on the boundary of the plate which is a circle. When one ant catches up with its previous ant, the game is over. Knowing the speed of ants, Pro
4、fessor Yang wants you to help him to adjust the distance between adjacent ants to make the game last longer.,Input The first line of the input is T (no more than 10000), which stands for the number of test cases you need to solve. Each test case begins with “N R”(without quotes) representing the num
5、ber of ants participating the game is N and the radius of the circle is R cm. The next line lists N integers and the i-th number is the speed (cm/s) of the i-th ant in clockwise direction. All numbers are positive integer not larger than 20. Output If the game can last forever, print “Inf” in a sing
6、le line, otherwise please output the longest time in seconds each game can last, which should be printed accurately rounded to three decimals.,Sample Input 2 3 1 1 1 1 3 1 3 2 1 Sample Output Inf 3.142,在样例中,3只蚂蚁连环追,第一只追第二只 第二只追第三只 第三只追不上第一只 所有蚂蚁都是相同速度则inf 最最关键的是Pi,如何计算(造成Wrong Answer的主要原因) acos(-1.0
7、),#include #include double pi=acos(-1.0); int v30; int main() int t,p,n,i; double r; scanf(“%d“, ,Archimedes,Description Mr. Wang has got a ball made of a certain kind of metal (assume the ball is uniform density). He wants to find out what the metal is by calculating the density of the ball. Mr. Wa
8、ng follows the story of Archimedes and crown. By putting the ball in the liquid (assume the liquid is deep enough). Mr. Wang can measure the height h indicated in the image. And the density of the liquid is d, the radius of the ball is R. Now Mr. Wang asks you to simply tell the density of the ball.
9、 You can assume the density of the ball is no greater than the liquid.h measures the height from the bottom of the ball to the liquid surface.,Input The input has many test cases. The first line is an integer T indicating the number of test cases. Following T lines there are three real numbers h, R,
10、 d.(0 h = 100, 0 R = 50,0 d = 100) Output For each test case, output one line with the answer, the density of the ball. round to 0.01. Please refer to the sample output.,Sample Input 2 9 9 1 9 8 1 Sample Output 0.50 0.59,整理得:,最最关键的是若小球不是漂浮,而是悬浮在水中(造成Wrong Answer的主要原因),#include #include double r; int
11、 main() int t,p; double h,d,v; scanf(“%d“, ,Flagstone Walk,Description There is a long flagstone walk on the way from the dormitory to the main hall. This flagstone walk has N lines and four flagstones arranged in each line. Hongshu always start from rightmost flagstone of the first line. In order t
12、o make this walk funny, he would always step onto the left or right flagstone in the next line if there is. For example, if Hongshu stands at the second rightmost flagstone of the third line, he would choose to step to the first or third rightmost one of the forth line. Note that Hongshu has only on
13、e choice when he is at the corner of one line.,Because Hongshu has to go to the main hall every day, he wants to know how many different ways to step across the flagstone walk. Can you help him?,Input The first line of the input is an integer T (T = 20), which stands for the number of test cases you
14、 need to solve. Each case consists of an integer N (1 = N = 20) on a single line, which stands for the length of the walk. Output For each case, print the number of ways on a single line.,Sample Input 3 2 3 4 Sample Output 1 2 3,DP11=1 DP22=DP31+DP11= 1 DP33=DP42+DP22=1 DP13=DP22=1 DP44=DP33=1 DP24=
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 简单 算题
链接地址:https://www.31doc.com/p-2542874.html