设为首页 加入收藏

TOP

PAT/查找元素习题集(二)
2017-10-12 10:12:40 】 浏览:10156
Tags:PAT/ 查找 元素 习题集
} 40 } 41 42 if(num == 0) printf("0\n"); 43 else printf("%d %s %s\n", num, oldest.name, youngest.name); 44 45 return 0; 46 }

 

B1032. 挖掘机技术哪家强 (20)

Description:

为了用事实说明挖掘机技术到底哪家强,PAT组织了一场挖掘机技能大赛。现请你根据比赛结果统计出技术最强的那个学校。

Input:

输入在第1行给出不超过105的正整数N,即参赛人数。随后N行,每行给出一位参赛者的信息和成绩,包括其所代表的学校的编号(从1开始连续编号)、及其比赛成绩(百分制),中间以空格分隔。

Output:

在一行中给出总得分最高的学校的编号、及其总分,中间以空格分隔。题目保证答案唯一,没有并列。

Sample Input:

6
3 65
2 80
1 100
2 70
3 40
3 0

Sample Output:

2 150

 1 #include <cstdio>
 2 
 3 const int maxn = 100010;  4 int school[maxn];  5 
 6 int main()  7 {  8     int n, schID, score;  9     scanf("%d", &n); 10     for(int i=0; i<n; ++i) { 11         scanf("%d%d", &schID, &score); 12         school[schID] += score; 13  } 14 
15     int k = 1, MAX = -1; 16     for(int i=1; i<=n; ++i) { 17         if(school[i] > MAX) { 18             MAX = school[i]; 19             k = i; 20  } 21  } 22 
23     printf("%d %d\n", k, MAX); 24 
25     return 0; 26 }

 

A1011. World Cup Betting (20)

Description:

With the 2010 FIFA World Cup running, football fans the world over were becoming increasingly excited as the best players from the best teams doing battles for the World Cup trophy in South Africa. Similarly, football betting fans were putting their money where their mouths were, by laying all manner of World Cup bets.

Chinese Football Lottery provided a "Triple Winning" game. The rule of winning was simple: first select any three of the games. Then for each selected game, bet on one of the three possible results -- namely W for win, T for tie, and L for lose. There was an odd assigned to each result. The winner's odd would be the product of the three odds times 65%.

For example, 3 games' odds are given as the following:

 W    T    L
1.1  2.5  1.7
1.2  3.0  1.6
4.1  1.2  1.1

To obtain the maximum profit, one must buy W for the 3rd game, T for the 2nd game, and T for the 1st game. If each bet takes 2 yuans, then the maximum profit would be (4.1*3.0*2.5*65%-1)*2 = 37.98 yuans (accurate up to 2 decimal places).

Input:

Each input file contains one test case. Each case contains the betting information of 3 games. Each game occupies a line with three distinct odds corresponding to W, T and L.

Output:

For each test case, print in one line the best bet of each game, and the maximum profit accurate up to 2 decimal places. The characters and the number must be separated by one space.

Sample Input:

1.1 2.5 1.7
1.2 3.0 1.6
4.1 1.2 1.1

Sample Output:

T T W 37.98

 1 #include <cstdio>
 2 
 3 char S[3] = {'W', 'T', 'L'};  4 
 5 int main()  6 {  7     double ans = 1, temp, a;  8     int idx;  9     for(int i=0; i<3; ++i) { 10         temp = 0; 11         for(int j=0; j<3; ++j) { 12             scanf("%lf", &a); 13             if(a > temp) { 14                 temp = a; 15                 idx = j; 16  } 17  } 18         ans *= temp; 19         printf("%c ", S[idx]); 20  } 21 
22     printf("%.2f\n", (ans*0.65-1)*2); 23 
24     return 0; 25 }

 

A1006. Sign In and Sign Out (25)

Description:

At the beginning of every day, the first person who signs in the computer room will unlock the door, and the last one who signs out will lock the door. Given the records of signing in's and out's, you are supposed to find the ones who have unlocked and locked the door on that day.

Input:

Each input file contains one test case. Each case contains the records for one day. The case starts with a positive integer M, which is the total number of records, followed by M lines, each in the format:

ID_number Sign_in_time Sign_out_time

where times are given in the format HH:MM:SS, and ID number is a string with no more than 15 characters.

Output:

For each test case, outpu

首页 上一页 1 2 3 4 下一页 尾页 2/4/4
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇C语言-预估校正法求常微分方程 下一篇学习C的笔记

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目