招来成分习题集,pat成分习题集

By admin in 4858.com on 2019年4月20日

B十0四.
成绩排名 (20)

B十04.
大成排行 (20)

PAT/查找成分习题集,pat成分习题集

B十0四. 成就排行 (20)

Description:

读入n名学生的人名、学号、战表,分别出口战表最高和大成最低学生的姓名和学号。

Input:

每种测试输入包括贰个测试用例,格式为:

第1行:正整数n
  第2行:第1个学生的姓名 学号 成绩
  第3行:第2个学生的姓名 学号 成绩
  ... ... ...
  第n+1行:第n个学生的姓名 学号 成绩

其间姓名和学号均为不超过拾2个字符的字符串,战绩为0到100里面包车型大巴2个整数,这里保险在一组测试用例中尚无八个学生的实际业绩是同样的。

Output:

对各种测试用例输出二行,第二行是成就最高学生的全名和学号,第1行是作育最低学生的真名和学号,字符串间有壹空格。

Sample Input:

3
Joe Math990112 89
Mike CS991301 100
Mary EE990830 95

Sample Output:

Mike CS991301
Joe Math990112

 1 #include <cstdio>
 2 
 3 struct Student{
 4     char name[15];
 5     char id[15];
 6     int score;
 7 }temp, ans_max, ans_min;
 8 
 9 int main()
10 {
11     int n;
12     scanf("%d", &n);
13     ans_max.score = -1;
14     ans_min.score = 101;
15     for(int i=0; i<n; ++i) {
16         scanf("%s%s%d", temp.name, temp.id, &temp.score);
17         if(temp.score > ans_max.score)  ans_max = temp;
18         if(temp.score < ans_min.score)  ans_min = temp;
19     }
20 
21     printf("%s %s\n%s %s\n", ans_max.name, ans_max.id, ans_min.name, ans_min.id);
22 
23     return 0;
24 }

 

B拾2八. 总人口普遍检查 (20)

Description:

某乡镇开展人口普遍检查,获得了壹切居民的呼和浩特。现请你写个程序,寻找镇上最年长和最青春的人。

那里确定保证每一种输入的日子都以官方的,但不料定是理所当然的——假若已知镇上未有超过200岁的老人,而后天是2014年十一月八日,所以超过200岁的八字和未落地的八字都是不客观的,应该被过滤掉。

Input:

输入在率先行提交正整数N,取值在(0,
105];随后N行,每行给出一位的人名(由不超过6个英文字母组成的字符串)、以及按“yyyy/mm/dd”(即年/月/日)格式给出的生辰。标题保障最年长和最年轻的人从未同仁一视。

Output:

在一行中逐条输出有效寿辰的个数、最年长人和最年轻人的全名,其间以空格分隔。

Sample Input:

5
John 2001/05/12
Tom 1814/09/06
Ann 2121/01/30
James 1814/09/05
Steve 1967/11/20

Sample Output:

3 Tom John

 1 #include <cstdio>
 2 #include <cstring>
 3 
 4 #define MaxSize 11
 5 struct birthday {
 6     char name[MaxSize];
 7     char date[MaxSize];
 8 }temp, maxn, minn;
 9 char floor[MaxSize] = "1814/09/06", upper[MaxSize] = "2014/09/06";
10 
11 int main()
12 {
13     //freopen("E:\\Temp\\input.txt", "r", stdin);
14 
15     for(int i=0; i<MaxSize; ++i) {
16         maxn.date[i] = floor[i];
17         minn.date[i] = upper[i];
18     }
19     int N;
20     scanf("%d", &N);
21     int counter = N;
22     for(int i=0; i<N; ++i) {
23         scanf("%s %s", temp.name, temp.date);
24         if(strcmp(temp.date, floor)<0 || strcmp(temp.date, upper)>0)
25             --counter;
26         else {
27             if(strcmp(temp.date, maxn.date) >= 0)   maxn = temp;
28             if(strcmp(temp.date, minn.date) <= 0)   minn = temp;
29         }
30     }
31 
32     if(counter != 0)
33         printf("%d %s %s\n", counter, minn.name, maxn.name);
34     else
35         printf("0\n");
36 
37     return 0;
38 }

 1 #include <cstdio>
 2 
 3 struct person {
 4     char name[10];
 5     int yy, mm, dd;
 6 }oldest, youngest, left, right, temp;
 7 
 8 bool LessEqu(person a, person b)
 9 {
10     if(a.yy != b. yy)   return a.yy <= b.yy;
11     else if(a.mm != b.mm)   return a.mm <= b.mm;
12     else return a.dd <= b.dd;
13 }
14 bool MoreEqu(person a, person b)
15 {
16     if(a.yy != b. yy)   return a.yy >= b.yy;
17     else if(a.mm != b.mm)   return a.mm >= b.mm;
18     else return a.dd >= b.dd;
19 }
20 void init()
21 {
22     youngest.yy = left.yy = 1814;
23     oldest.yy = right.yy = 2014;
24     youngest.mm = oldest.mm = left.mm = right.mm = 9;
25     youngest.dd = oldest.dd = left.dd = right.dd = 6;
26 }
27 
28 int main()
29 {
30     init();
31     int n, num = 0;
32     scanf("%d", &n);
33     for(int i=0; i<n; ++i) {
34         scanf("%s %d/%d/%d", temp.name, &temp.yy, &temp.mm, &temp.dd);
35         if(MoreEqu(temp, left) && LessEqu(temp, right)) {
36             num++;
37             if(LessEqu(temp, oldest))  oldest = temp;
38             if(MoreEqu(temp, youngest)) youngest = temp;
39         }
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 }

 

B十32. 推土机才能哪家强 (20)

Description:

为了用事实表达开掘机技巧到底哪家强,PAT协会了一场发现机才能大赛。现请你依照比赛结果总括出才干最强的不胜高校。

Input:

输入在第一行提交不超过十5的正整数N,即参加比赛人数。随后N行,每行给出一个鬼盖赛者的新闻和成绩,包涵其所代表的学堂的数码(从一上马一而再编号)、及其竞技战绩(百分制),中间以空格分隔。

Output:

在1行中提交总得分最高的这个学校的号码、及其总分,中间以空格分隔。标题保证答案唯壹,未有同等对待。

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 }

 

B拾04. 大成排行(20) Description:
读入n名学生的姓名、学号、成绩,分别出口成绩最高和实际业绩最低学生的姓…

1011. World Cup Betting (20)

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 L for the 1st game. If each bet takes 2 yuans, then the
maximum profit would be (4.13.02.565%-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

Description:

Description:

代码如下

#include<iostream>
using namespace std;
int main(){
    double profit=1,odd;
    int tag; 
    char ch[4]={'W','T','L'};
    for(int i=0;i<3;i++){
        double max=0;
        for(int j=0;j<3;j++){
            cin>>odd;
            if(odd>max){
                max=odd;
                tag=j;
            }
        }
        profit*=max;
        cout<<ch[tag]<<" ";
    }
    profit=(profit*0.65-1)*2;
    printf("%.2f",profit);
}

读入n名学生的人名、学号、战表,分别出口战绩最高和培养最低学生的全名和学号。

读入n名学生的姓名、学号、战表,分别出口成绩最高和大成最低学生的真名和学号。

Input:

Input:

每种测试输入包蕴2个测试用例,格式为:

各样测试输入蕴含三个测试用例,格式为:

第1行:正整数n
  第2行:第1个学生的姓名 学号 成绩
  第3行:第2个学生的姓名 学号 成绩
  ... ... ...
  第n+1行:第n个学生的姓名 学号 成绩
第1行:正整数n
  第2行:第1个学生的姓名 学号 成绩
  第3行:第2个学生的姓名 学号 成绩
  ... ... ...
  第n+1行:第n个学生的姓名 学号 成绩

中间姓名和学号均为不超越拾个字符的字符串,成绩为0到100之间的二个整数,那里保险在壹组测试用例中尚无五个学生的实际业绩是同样的。

其间姓名和学号均为不超越12个字符的字符串,战表为0到100之间的2个平头,那里有限帮衬在1组测试用例中平昔不多少个学生的成便是一模一样的。

Output:

Output:

招来成分习题集,pat成分习题集。对每个测试用例输出2行,第一行是战绩最高学生的人名和学号,第一行是成就最低学生的姓名和学号,字符串间有壹空格。

对各种测试用例输出2行,第贰行是成就最高学生的真名和学号,第一行是培育最低学生的人名和学号,字符串间有一空格。

Sample
Input:

Sample
Input:

3
Joe
Math990112 89
Mike
CS991301 100
Mary
EE990830 95

3
Joe
Math990112 89
Mike
CS991301 100
Mary
EE990830 95

Sample
Output:

Sample
Output:

Mike
CS991301
Joe
Math990112

Mike
CS991301
Joe
Math990112

 1 #include <cstdio>
 2 
 3 struct Student{
 4     char name[15];
 5     char id[15];
 6     int score;
 7 }temp, ans_max, ans_min;
 8 
 9 int main()
10 {
11     int n;
12     scanf("%d", &n);
13     ans_max.score = -1;
14     ans_min.score = 101;
15     for(int i=0; i<n; ++i) {
16         scanf("%s%s%d", temp.name, temp.id, &temp.score);
17         if(temp.score > ans_max.score)  ans_max = temp;
18         if(temp.score < ans_min.score)  ans_min = temp;
19     }
20 
21     printf("%s %s\n%s %s\n", ans_max.name, ans_max.id, ans_min.name, ans_min.id);
22 
23     return 0;
24 }
 1 #include <cstdio>
 2 
 3 struct Student{
 4     char name[15];
 5     char id[15];
 6     int score;
 7 }temp, ans_max, ans_min;
 8 
 9 int main()
10 {
11     int n;
12     scanf("%d", &n);
13     ans_max.score = -1;
14     ans_min.score = 101;
15     for(int i=0; i<n; ++i) {
16         scanf("%s%s%d", temp.name, temp.id, &temp.score);
17         if(temp.score > ans_max.score)  ans_max = temp;
18         if(temp.score < ans_min.score)  ans_min = temp;
19     }
20 
21     printf("%s %s\n%s %s\n", ans_max.name, ans_max.id, ans_min.name, ans_min.id);
22 
23     return 0;
24 }

 

 

B拾2八.
总人口普遍检查 (20)

B拾28.
总人口普遍检查 (20)

Description:

Description:

某乡镇进行人口普遍检查,获得了百分百居民的八字。现请你写个程序,找寻镇上最年长和最青春的人。

某乡镇拓展人口普遍检查,获得了全体居民的生辰。现请你写个程序,寻觅镇上最年长和最青春的人。

此地确定保障各个输入的日子都是官方的,但不必然是创立的——若是已知镇上未有超越200岁的老1辈,而前几日是201肆年4月二二十二十七日,所以当先200岁的生辰和未落地的生日都以不创设的,应该被过滤掉。

此处确认保证每种输入的日子都以官方的,但不鲜明是理所当然的——如果已知镇上未有超过200岁的长者,而后天是201四年4月1日,所以超越200岁的三亚和未出生的八字都以不制造的,应该被过滤掉。

Input:

Input:

输入在第二行提交正整数N,取值在(0,
5];随后N行,每行给出一个人的全名(由不超越5个英文字母组成的字符串)、以及按“yyyy/mm/dd”(即年/月/日)格式给出的出生之日。标题保障最年长和最青春的人绝非人己一视。

输入在首先行提交正整数N,取值在(0,
105];随后N行,每行给出一个人的真名(由不超越陆个英文字母组成的字符串)、以及按“yyyy/mm/dd”(即年/月/日)格式给出的生日。标题保证最年长和最年轻的人未有比量齐观。

Output:

Output:

在1行中各类输出有效诞辰的个数、最年长人和最年轻人的姓名,其间以空格分隔。

在1行中相继输出有效生日的个数、最年长人和最年轻人的全名,其间以空格分隔。

Sample
Input:

Sample
Input:

5
John
2001/05/12
Tom
1814/09/06
Ann
2121/01/30
James
1814/09/05
Steve
1967/11/20

5
John
2001/05/12
Tom
1814/09/06
Ann
2121/01/30
James
1814/09/05
Steve
1967/11/20

Sample
Output:

Sample
Output:

3 Tom
John

3 Tom
John

 1 #include <cstdio>
 2 #include <cstring>
 3 
 4 #define MaxSize 11
 5 struct birthday {
 6     char name[MaxSize];
 7     char date[MaxSize];
 8 }temp, maxn, minn;
 9 char floor[MaxSize] = "1814/09/06", upper[MaxSize] = "2014/09/06";
10 
11 int main()
12 {
13     //freopen("E:\\Temp\\input.txt", "r", stdin);
14 
15     for(int i=0; i<MaxSize; ++i) {
16         maxn.date[i] = floor[i];
17         minn.date[i] = upper[i];
18     }
19     int N;
20     scanf("%d", &N);
21     int counter = N;
22     for(int i=0; i<N; ++i) {
23         scanf("%s %s", temp.name, temp.date);
24         if(strcmp(temp.date, floor)<0 || strcmp(temp.date, upper)>0)
25             --counter;
26         else {
27             if(strcmp(temp.date, maxn.date) >= 0)   maxn = temp;
28             if(strcmp(temp.date, minn.date) <= 0)   minn = temp;
29         }
30     }
31 
32     if(counter != 0)
33         printf("%d %s %s\n", counter, minn.name, maxn.name);
34     else
35         printf("0\n");
36 
37     return 0;
38 }

 1 #include <cstdio>
 2 
 3 struct person {
 4     char name[10];
 5     int yy, mm, dd;
 6 }oldest, youngest, left, right, temp;
 7 
 8 bool LessEqu(person a, person b)
 9 {
10     if(a.yy != b. yy)   return a.yy <= b.yy;
11     else if(a.mm != b.mm)   return a.mm <= b.mm;
12     else return a.dd <= b.dd;
13 }
14 bool MoreEqu(person a, person b)
15 {
16     if(a.yy != b. yy)   return a.yy >= b.yy;
17     else if(a.mm != b.mm)   return a.mm >= b.mm;
18     else return a.dd >= b.dd;
19 }
20 void init()
21 {
22     youngest.yy = left.yy = 1814;
23     oldest.yy = right.yy = 2014;
24     youngest.mm = oldest.mm = left.mm = right.mm = 9;
25     youngest.dd = oldest.dd = left.dd = right.dd = 6;
26 }
27 
28 int main()
29 {
30     init();
31     int n, num = 0;
32     scanf("%d", &n);
33     for(int i=0; i<n; ++i) {
34         scanf("%s %d/%d/%d", temp.name, &temp.yy, &temp.mm, &temp.dd);
35         if(MoreEqu(temp, left) && LessEqu(temp, right)) {
36             num++;
37             if(LessEqu(temp, oldest))  oldest = temp;
38             if(MoreEqu(temp, youngest)) youngest = temp;
39         }
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 }
 1 #include <cstdio>
 2 #include <cstring>
 3 
 4 #define MaxSize 11
 5 struct birthday {
 6     char name[MaxSize];
 7     char date[MaxSize];
 8 }temp, maxn, minn;
 9 char floor[MaxSize] = "1814/09/06", upper[MaxSize] = "2014/09/06";
10 
11 int main()
12 {
13     //freopen("E:\\Temp\\input.txt", "r", stdin);
14 
15     for(int i=0; i<MaxSize; ++i) {
16         maxn.date[i] = floor[i];
17         minn.date[i] = upper[i];
18     }
19     int N;
20     scanf("%d", &N);
21     int counter = N;
22     for(int i=0; i<N; ++i) {
23         scanf("%s %s", temp.name, temp.date);
24         if(strcmp(temp.date, floor)<0 || strcmp(temp.date, upper)>0)
25             --counter;
26         else {
27             if(strcmp(temp.date, maxn.date) >= 0)   maxn = temp;
28             if(strcmp(temp.date, minn.date) <= 0)   minn = temp;
29         }
30     }
31 
32     if(counter != 0)
33         printf("%d %s %s\n", counter, minn.name, maxn.name);
34     else
35         printf("0\n");
36 
37     return 0;
38 }

 1 #include <cstdio>
 2 
 3 struct person {
 4     char name[10];
 5     int yy, mm, dd;
 6 }oldest, youngest, left, right, temp;
 7 
 8 bool LessEqu(person a, person b)
 9 {
10     if(a.yy != b. yy)   return a.yy <= b.yy;
11     else if(a.mm != b.mm)   return a.mm <= b.mm;
12     else return a.dd <= b.dd;
13 }
14 bool MoreEqu(person a, person b)
15 {
16     if(a.yy != b. yy)   return a.yy >= b.yy;
17     else if(a.mm != b.mm)   return a.mm >= b.mm;
18     else return a.dd >= b.dd;
19 }
20 void init()
21 {
22     youngest.yy = left.yy = 1814;
23     oldest.yy = right.yy = 2014;
24     youngest.mm = oldest.mm = left.mm = right.mm = 9;
25     youngest.dd = oldest.dd = left.dd = right.dd = 6;
26 }
27 
28 int main()
29 {
30     init();
31     int n, num = 0;
32     scanf("%d", &n);
33     for(int i=0; i<n; ++i) {
34         scanf("%s %d/%d/%d", temp.name, &temp.yy, &temp.mm, &temp.dd);
35         if(MoreEqu(temp, left) && LessEqu(temp, right)) {
36             num++;
37             if(LessEqu(temp, oldest))  oldest = temp;
38             if(MoreEqu(temp, youngest)) youngest = temp;
39         }
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 }

 

 

B十3贰.
开掘机技能哪家强 (20)

B十3二.
推土机技巧哪家强 (20)

Description:

Description:

为了用真情注脚开采机技能到底哪家强,PAT协会了一场发现机技能大赛。现请你依照比赛结果总结出才干最强的卓殊高校。

为了用实际表达发现机才干到底哪家强,PAT协会了一场开掘机才能大赛。现请你根据比赛结果总计出才干最强的充裕学校。

Input:

Input:

输入在第2行提交不当先105的正整数N,即参加比赛人数。随后N行,每行给出一黄参加比赛者的音讯和大成,包蕴其所表示的学府的号码(从一上马一而再编号)、及其竞赛战绩(百分制),中间以空格分隔。

输入在第一行提交不超过拾5的正整数N,即参加比赛人数。随后N行,每行给出一个野山参加比赛者的新闻和成就,包罗其所代表的母校的号子(从一从头接2连叁编号)、及其竞赛战表(百分制),中间以空格分隔。

Output:

Output:

在一行中付出总得分最高的母校的号码、及其总分,中间以空格分隔。标题保证答案唯1,未有同等对待。

在壹行中提交总得分最高的这个学院的编号、及其总分,中间以空格分隔。标题保障答案唯壹,未有比量齐观。

Sample
Input:

Sample
Input:

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

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

Sample
Output:

Sample
Output:

2
150

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 }
 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)

A1011.
World Cup Betting (20)

Description:

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.

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%.

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:

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
 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*4858.com,2.5*65%-1)*2 = 37.98 yuans
(accurate up to 2 decimal places).

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:

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.

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:

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.

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:

Sample
Input:

1.1
2.5 1.7
1.2
3.0 1.6
4.1
1.2 1.1

1.1
2.5 1.7
1.2
3.0 1.6
4.1
1.2 1.1

Sample
Output:

Sample
Output:

T T W
37.98

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 }
 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)

A1006.
Sign In and Sign Out (25)

Description:

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.

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:

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:

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
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.

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

Output:

Output:

For
each test case, output in one line the ID numbers of the persons who
have unlocked and locked the door on that day. The two ID numbers must
be separated by one space.

For
each test case, output in one line the ID numbers of the persons who
have unlocked and locked the door on that day. The two ID numbers must
be separated by one space.

Note:
It is guaranteed that the records are consistent. That is, the sign in
time must be earlier than the sign out time for each person, and there
are no two persons sign in or out at the same moment.

Note:
It is guaranteed that the records are consistent. That is, the sign in
time must be earlier than the sign out time for each person, and there
are no two persons sign in or out at the same moment.

Sample
Input:

Sample
Input:

3
CS301111
15:30:28 17:00:10
SC3021234
08:00:00 11:25:25
CS301133
21:45:00 21:58:40

3
CS301111
15:30:28 17:00:10
SC3021234
08:00:00 11:25:25
CS301133
21:45:00 21:58:40

Sample
Output:

Sample
Output:

SC3021234
CS301133

SC3021234
CS301133

 1 #include <cstdio>
 2 #include <cstring>
 3 
 4 #define MaxSize 20
 5 struct Person {
 6     char id[MaxSize];
 7     char in[MaxSize];
 8     char out[MaxSize];
 9 }temp, In, Out;
10 
11 int main()
12 {
13     //freopen("E:\\Temp\\input.txt", "r", stdin);
14 
15     char a[] = "00:00:00", b[] = "23:59:59";
16     for(int i=0; i<9; ++i) {
17         In.in[i] = Out.in[i]  = b[i];
18         In.out[i] = Out.out[i]  = a[i];
19     }
20     int N;
21     scanf("%d", &N);
22     for(int i=0; i<N; ++i) {
23         scanf("%s %s %s", temp.id, temp.in, temp.out);
24         if(strcmp(temp.in, In.in) < 0) In = temp;
25         if(strcmp(temp.out, Out.out) > 0) Out = temp;
26     }
27 
28     printf("%s %s\n", In.id, Out.id);
29 
30     return 0;
31 }

 1 #include <cstdio>
 2 
 3 struct pNode {
 4     char id[20];
 5     int hh, mm, ss;
 6 }temp, ans1, ans2;
 7 
 8 bool great(pNode node1, pNode node2) {
 9     if(node1.hh != node2.hh)    return node1.hh > node2.hh;
10     if(node1.mm != node2.mm)    return node1.mm > node2.mm;
11     return node1.ss > node2.ss;
12 }
13 
14 int main()
15 {
16     int n;
17     scanf("%d", &n);
18     ans1.hh = 24, ans1.mm = 60, ans1.ss = 60;
19     ans2.hh = 0, ans2.mm = 0, ans2.ss = 0;
20     for(int i=0; i<n; ++i) {
21         scanf("%s %d:%d:%d", temp.id, &temp.hh, &temp.mm, &temp.ss);
22         if(great(temp, ans1) == false)  ans1 = temp;
23         scanf("%d:%d:%d", &temp.hh, &temp.mm, &temp.ss);
24         if(great(temp, ans2) == true)   ans2 = temp;
25     }
26 
27     printf("%s %s\n", ans1.id, ans2.id);
28 
29     return 0;
30 }
 1 #include <cstdio>
 2 #include <cstring>
 3 
 4 #define MaxSize 20
 5 struct Person {
 6     char id[MaxSize];
 7     char in[MaxSize];
 8     char out[MaxSize];
 9 }temp, In, Out;
10 
11 int main()
12 {
13     //freopen("E:\\Temp\\input.txt", "r", stdin);
14 
15     char a[] = "00:00:00", b[] = "23:59:59";
16     for(int i=0; i<9; ++i) {
17         In.in[i] = Out.in[i]  = b[i];
18         In.out[i] = Out.out[i]  = a[i];
19     }
20     int N;
21     scanf("%d", &N);
22     for(int i=0; i<N; ++i) {
23         scanf("%s %s %s", temp.id, temp.in, temp.out);
24         if(strcmp(temp.in, In.in) < 0) In = temp;
25         if(strcmp(temp.out, Out.out) > 0) Out = temp;
26     }
27 
28     printf("%s %s\n", In.id, Out.id);
29 
30     return 0;
31 }

 1 #include <cstdio>
 2 
 3 struct pNode {
 4     char id[20];
 5     int hh, mm, ss;
 6 }temp, ans1, ans2;
 7 
 8 bool great(pNode node1, pNode node2) {
 9     if(node1.hh != node2.hh)    return node1.hh > node2.hh;
10     if(node1.mm != node2.mm)    return node1.mm > node2.mm;
11     return node1.ss > node2.ss;
12 }
13 
14 int main()
15 {
16     int n;
17     scanf("%d", &n);
18     ans1.hh = 24, ans1.mm = 60, ans1.ss = 60;
19     ans2.hh = 0, ans2.mm = 0, ans2.ss = 0;
20     for(int i=0; i<n; ++i) {
21         scanf("%s %d:%d:%d", temp.id, &temp.hh, &temp.mm, &temp.ss);
22         if(great(temp, ans1) == false)  ans1 = temp;
23         scanf("%d:%d:%d", &temp.hh, &temp.mm, &temp.ss);
24         if(great(temp, ans2) == true)   ans2 = temp;
25     }
26 
27     printf("%s %s\n", ans1.id, ans2.id);
28 
29     return 0;
30 }

 

 

A1036.
Boys vs Girls (25)

A1036.
Boys vs Girls (25)

Description:

Description:

This
time you are asked to tell the difference between the lowest grade of
all the male students and the highest grade of all the female
students.

This
time you are asked to tell the difference between the lowest grade of
all the male students and the highest grade of all the female
students.

Input:

Input:

Each
input file contains one test case. Each case contains a positive integer
N, followed by N lines of student information. Each line contains a
student’s name, gender, ID and grade, separated by a space, where name
and ID are strings of no more than 10 characters with no space, gender
is either F (female) or M (male), and grade is an integer between 0 and

Each
input file contains one test case. Each case contains a positive integer
N, followed by N lines of student information. Each line contains a
student’s name, gender, ID and grade, separated by a space, where name
and ID are strings of no more than 10 characters with no space, gender
is either F (female) or M (male), and grade is an integer between 0 and

  1. It is guaranteed that all the grades are distinct.
  1. It is guaranteed that all the grades are distinct.

Output:

Output:

For
each test case, output in 3 lines. The first line gives the name and ID
of the female student with the highest grade, and the second line gives
that of the male student with the lowest grade. The third line gives the
difference gradeF-gradeM. If one such kind of
student is missing, output “Absent” in the corresponding line, and
output “NA” in the third line instead.

For
each test case, output in 3 lines. The first line gives the name and ID
of the female student with the highest grade, and the second line gives
that of the male student with the lowest grade. The third line gives the
difference gradeF-gradeM. If one such kind of
student is missing, output “Absent” in the corresponding line, and
output “NA” in the third line instead.

Sample
Input1:

Sample
Input1:

3

3

Joe M
Math990112 89

Joe M
Math990112 89

Mike M
CS991301 100

Mike M
CS991301 100

Mary F
EE990830 95

Mary F
EE990830 95

Sample
Output1:

Sample
Output1:

Mary
EE990830

Mary
EE990830

Joe
Math990112

Joe
Math990112

6

6

Sample
Input 2:

Sample
Input 2:

1

1

Jean M
AA980920 60

Jean M
AA980920 60

Sample
Output 2:

Sample
Output 2:

Absent

Absent

Jean
AA980920

Jean
AA980920

NA

NA

 1 #include <cstdio>
 2 
 3 struct person {
 4     char name[15];
 5     char id[15];
 6     int score;
 7 }M, F, temp;
 8 
 9 void init()
10 {
11     M.score = 101;
12     F.score = -1;
13 }
14 
15 int main()
16 {
17     init();
18     int n;
19     char gender;
20     scanf("%d", &n);
21     for(int i=0; i<n; ++i) {
22         scanf("%s %c %s %d", temp.name, &gender, temp.id, &temp.score);
23         if(gender=='M' && temp.score<M.score) M = temp;
24         else if(gender=='F' && temp.score>F.score)  F = temp;
25     }
26 
27     if(F.score == -1)   printf("Absent\n");
28     else printf("%s %s\n", F.name, F.id);
29     if(M.score == 101)  printf("Absent\n");
30     else printf("%s %s\n", M.name, M.id);
31     if(F.score==-1 || M.score==101) printf("NA\n");
32     else printf("%d\n", F.score-M.score);
33 
34     return 0;
35 }
 1 #include <cstdio>
 2 
 3 struct person {
 4     char name[15];
 5     char id[15];
 6     int score;
 7 }M, F, temp;
 8 
 9 void init()
10 {
11     M.score = 101;
12     F.score = -1;
13 }
14 
15 int main()
16 {
17     init();
18     int n;
19     char gender;
20     scanf("%d", &n);
21     for(int i=0; i<n; ++i) {
22         scanf("%s %c %s %d", temp.name, &gender, temp.id, &temp.score);
23         if(gender=='M' && temp.score<M.score) M = temp;
24         else if(gender=='F' && temp.score>F.score)  F = temp;
25     }
26 
27     if(F.score == -1)   printf("Absent\n");
28     else printf("%s %s\n", F.name, F.id);
29     if(M.score == 101)  printf("Absent\n");
30     else printf("%s %s\n", M.name, M.id);
31     if(F.score==-1 || M.score==101) printf("NA\n");
32     else printf("%d\n", F.score-M.score);
33 
34     return 0;
35 }

 

 

发表评论

电子邮件地址不会被公开。 必填项已用*标注

网站地图xml地图
Copyright @ 2010-2019 美高梅手机版4858 版权所有