1、7th后浙大ACM总结第一次ACM总结(7th ACM)ZOJ Problem Set 1001 A + B Problem 1ZOJ Problem Set 1037 Gridland 2ZOJ Problem Set 1045 HangOver 4ZOJ Problem Set 1048 Financial Management 6ZOJ Problem Set 1049 I Think I Need a Houseboat 8ZOJ Problem Set 1067 Color Me Less 11ZOJ Problem Set 1073 Round and Round We Go 14
2、ZOJ Problem Set 1113 u Calculate e 17ZOJ Problem Set 1115 Digital Roots 19ZOJ Problem Set 1151 Word Reversal 21ZOJ Problem Set 1216 Deck 23ZOJ Problem Set - 1240 IBM Minus One 25ZOJ Problem Set - 1241 Geometry Made Simple 27ZOJ Problem Set - 1251 Box of Bricks 30ZOJ Problem Set - 1292 Integer Inquir
3、y 32ZOJ Problem Set - 1331 Perfect Cubes 34ZOJ Problem Set - 1337 Pi 36ZOJ Problem Set - 1350 The Drunk Jailer 39ZOJ Problem Set - 1382 A Simple Task 41ZOJ Problem Set - 1712 Skew Binary 43ZOJ Problem Set - 1730 Crazy Tea Party 45ZOJ Problem Set - 1760 Doubles 47ZOJ Problem Set - 1763 A Simple Quest
4、ion of Chemistry 49ZOJ Problem Set - 1797 Least Common Multiple 52ZOJ Problem Set - 1871 Steps 54ZOJ Problem Set - 1879 Jolly Jumpers /又是没有代码 56ZOJ Problem Set - 1915 Above Average 58ZOJ Problem Set - 2001 Adding Reversed Numbers 60ZOJ Problem Set - 2201 No Brainer 63ZOJ Problem Set - 2388 Beat the
5、Spread! 65ZOJ Problem Set - 2947 Abbreviation 67ZOJ Problem Set - 2965 Accurately Say CocaCola! 70ZOJ Problem Set - 2969 Easy Task 72ZOJ Problem Set - 2970 Faster, Higher, Stronger 74ZOJ Problem Set - 2987 Misspelling 77ZOJ Problem Set - 2988 Conversions 79ZOJ Problem Set 3313 Clock/没有代码 82ZOJ Probl
6、em Set 3322 Who is Older? 83ZOJ Problem Set - 3323 Somali Pirates 85ZOJ Problem Set - 3328 Wu Xing 87ZOJ Problem Set - 3333 Guess the Price 90附录:ACM常见单词表 92ZOJ Problem Set 1001 A + B ProblemTime Limit: 1 Second Memory Limit: 32768 KB Calculate计算 a + b InputThe input will consist of a series of pairs
7、 of integers a and b,separated by a space, one pair of integers per line. OutputFor each pair of input integers a and b you should output the sum of a and b in one line,and with one line of output for each line in input. Sample Input1 5Sample Output6思路:略代码呈现:#includeint main() int a,b; while(scanf(%
8、d%d,&a,&b)!=EOF) /无限输入直到遇见shift+F6停止 printf(%dn,a+b); return 0;代码效果:ZOJ Problem Set 1037 GridlandTime Limit: 1 Second Memory Limit: 32768 KB BackgroundFor years, computer scientists have been trying to find efficient solutions to different computing计算 problems. For some of them efficient algorithms算
9、法 are already available, these are the easy problems like sorting整理;排序;分类拣选, evaluating a polynomial多项式 or finding the shortest path in a graph. For the hard ones only exponential-time algorithms指数时间算法 are known. The traveling-salesman problem belongs to this latter group. Given a set of N towns and
10、 roads between these towns, the problem is to compute the shortest path allowing a salesman to visit each of the towns once and only once and return to the starting point.ProblemThe president of Gridland has hired you to design a program that calculates the length of the shortest traveling-salesman
11、tour for the towns in the country. In Gridland, there is one town at each of the points of a rectangular grid直角坐标网. Roads run from every town in the directions North, Northwest, West, Southwest, South, Southeast, East, and Northeast, provided that there is a neighboring town in that direction. The d
12、istance between neighboring towns in directions North-South or East-West is 1 unit. The length of the roads is measured by the Euclidean distance欧几里得距离. For example, Figure 7 shows 2 * 3-Gridland, i.e., a rectangular grid of dimensions 规模,大小 2 by 3. In 2 * 3-Gridland, the shortest tour has length 6.
13、 Figure 7: A traveling-salesman tour in 2 * 3-Gridland.InputThe first line contains the number of scenarios剧情(情况).For each scenario, the grid dimensions m and n will be given as two integer numbers in a single line, separated by a single blank, satisfying 1 m 50 and 1 n 50.OutputThe output for each
14、scenario begins with a line containing Scenario #i:, where i is the number of the scenario starting at 1. In the next line, print the length of the shortest traveling-salesman tour rounded to two decimal digits. The output for every scenario ends with a blank line.Sample Input22 22 3Sample OutputSce
15、nario #1:4.00Scenario #2:6.00 思路:如果城镇数是偶数,即分布的行和列至少有一个是偶数的时候,我们可以一个个走,正好最后一次回到起始城镇,即m*n;如果是奇数,就是说分布的行和列都是奇数,那么我们倒数第二次到的城镇和起点城镇之间相距斜线,即m*n-1+根号2。代码呈现:#include #include int main(void) int k,i=1; float m,n; scanf(%d,&k); /循环执行的次数 while(k-) scanf(%f%f,&m,&n); if(int)m%2!=0&(int)n%2!=0) printf(Scenario #
16、%d:n%.2fnn,i,m*n-1+sqrt(2); else printf(Scenario #%d:n%.2fnn,i,n*m); return 0;代码效果: ZOJ Problem Set 1045 HangOverTime Limit: 1 Second Memory Limit: 32768 KB How far can you make a stack of cards overhang a table? If you have one card, you can create a maximum overhang of half a card length. (Were as
17、suming假设 that the cards must be perpendicular to the table.) With two cards you can make the top card overhang the bottom one by half a card length, and the bottom one overhang the table by a third of a card length, for a total maximum overhang of 1/2 + 1/3 = 5/6 card lengths. In general you can mak
18、e n cards overhang by 1/2 + 1/3 + 1/4 + . + 1/(n + 1) card lengths, where the top card overhangs the second by 1/2, the second overhangs the third by 1/3, the third overhangs the fourth by 1/4, etc., and the bottom card overhangs the table by 1/(n + 1). This is illustrated 有插图的in the figure below.Th
19、e input consists of one or more test cases, followed by a line containing the number 0.00 that signals the end of the input. Each test case is a single line containing a positive floating-point number c whose value is at least 0.01 and at most 5.20; c will contain exactly three digits.For each test
20、case, output the minimum number of cards necessary to achieve an overhang of at least c card lengths. Use the exact output format shown in the examples.Example input:1.003.710.045.190.00Example output:3 card(s)61 card(s)1 card(s)273 card(s) 思路:题意:输入的小数在0.01-5.20之间,输出满足1/2+1/3+1/(n+1)稍大于小数的n的值1.无限输入小
21、数2.判断该小数是否在0.01-5.20之间3.对1/2+1/3+1/(n+1)进行累加,同时判断该式子是否大于小数,是则输出n。不是则继续循环直至是代码呈现:#includeint main() float a; double s; int n; while(scanf(%f,&a)!=EOF&a!=0.00) s=0.00; n=1; if(a=0.01&as;n+) s+=1.0/(n+1); printf(%d card(s)n,n-1); return 0;代码效果:ZOJ Problem Set 1048 Financial ManagementTime Limit: 1 Seco
22、nd Memory Limit: 32768 KB Larry graduated this year and finally has a job. Hes making a lot of money, but somehow never seems to have enough. Larry has decided that he needs to grab hold of控制、抓住 his financial portfolio and solve his financing problems. The first step is to figure out whats been goin
23、g on with his money. Larry has his bank account statements and wants to see how much money he has. Help Larry by writing a program to take his closing balance from each of the past twelve months and calculate his average account balance账户余额. Input Format: The input will be twelve lines. Each line wi
24、ll contain the closing balance终期余额of his bank account银行存款for a particular month. Each number will be positive and displayed to the penny. No dollar sign will be included. Output Format: The output will be a single number, the average (mean) of the closing balances for the twelve months. It will be r
25、ounded to the nearest penny, preceded immediately by a dollar sign, and followed by the end-of-line. There will be no other spaces or characters in the output. Sample Input: 100.00 489.12 12454.12 1234.10 823.05 109.20 5.27 1542.25 839.18 83.99 1295.01 1.75 Sample Output: $1581.42 思路:求12个浮点型实数的和,然后求
26、平均输出注:输出$时的格式是printf($%.2f,s);代码呈现:#includevoid main() int i; float a,s; s=0.0; for(i=0;i12;i+) scanf(%f,&a); s=s+a; s=s/12; printf($%.2fn,s); 代码效果:ZOJ Problem Set 1049 I Think I Need a HouseboatTime Limit: 1 Second Memory Limit: 32768 KB Fred Mapper is considering purchasing购买,获得 some land in Louis
27、iana to build his house on. In the process of investigating调查;审查 the land, he learned that the state of Louisiana is actually shrinking退缩 by 50 square miles each year, due to erosion侵蚀,腐蚀 caused by the Mississippi River. Since Fred is hoping to live in this house the rest of his life, he needs to kn
28、ow if his land is going to be lost to erosion. After doing more research, Fred has learned that the land that is being lost forms a semicircle半圆,半圆形. This semicircle is part of a circle centered at (0,0), with the line that bisects二等分 the circle being the X axisX轴. Locations below the X axis are in
29、the water. The semicircle has an area of 0 at the beginning of year 1. (Semicircle illustrated in the Figure.) Input Format: The first line of input will be a positive integer indicating how many data sets will be included (N). Each of the next N lines will contain the X and Y Cartesian coordinates笛
30、卡儿坐标 of the land Fred is considering. These will be floating point numbers measured in miles. The Y coordinate will be non-negative. (0,0) will not be given. Output Format: For each data set, a single line of output should appear. This line should take the form of: Property N: This property will begin eroding in year Z. Where N is the data set (counting from 1), and Z is the first year (start from 1) this property will be within the semicircle AT THE END OF YEAR Z. Z must be an integer. After the last data set, this should print out END OF OUTPUT.
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1