2017中国大学生程序设计竞赛 - 女生专场(重现)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了2017中国大学生程序设计竞赛 - 女生专场(重现)相关的知识,希望对你有一定的参考价值。

A.Automatic Judge(模拟)

Problem Description

Welcome to HDU to take part in the second CCPC girls’ competition!A new automatic judge system is used for this competition. During the five-hour contest time, you can submit your code to the system, then the judge will reply you. Here is a list of the judge‘s replies and their meaning:1. Accepted(AC): Yes, your program is correct. You did a good job!2. PresentationError(PE) : Your program‘s output format is not exactly the same as required by the problem, although the output is correct. This usually means the existence of omitted or extra blank characters (white spaces, tab characters and/or new line characters) between any two non-blank characters, and/or blank lines (a line consisting of only blank characters) between any two non-blank lines. Trailing blank characters at the end of each line and trailing blank lines at the of output are not considered format errors. Check the output for spaces, blank lines, etc. against the problem‘s output specification.3. WrongAnswer(WA) : Correct solution not reached for the inputs. The inputs and outputs that we use to test the programs are not public (it is recomendable to get accustomed to a true contest dynamic :-)4. RuntimeError(RE) : Your program failed during the execution and you will receive the hints for the reasons.5. TimeLimitExceeded(TLE) : Your program tried to run during too much time.6. MemoryLimitExceeded(MLE): Your program tried to use more memory than the judge default settings.7. OutputLimitExceeded(OLE): Your program tried to write too much information. This usually occurs if it goes into a infinite loop.8. CompilationError(CE): The compiler fails to compile your program. Warning messages are not considered errors. Click on the judge‘s reply to see the warning and error messages produced by the compiler.For each submission, if it is the first time that the judge returns ``AC‘‘ on this problem, then it means you have passed this problem, and the current time will be added to the penalty of your team. In addition, every time you pass a problem, each unsuccessful try for that problem before is counted as 20 minutes penalty, it should also be added to the penalty of your team.Now given the number of problems in the contest and the submission records of a team. Please write a program to calculate the number of problems the team passed and their penalty.

 

Input

The first line of the input contains an integer T(1≤T≤20), denoting the number of test cases.In each test case, there are two integers n(1≤n≤13) and m(1≤m≤100) in the first line, denoting the number of problems and the number of submissions of a team. Problems are labeled by 1001, 1002, ..., 1000+n.In the following m lines, each line contains an integer x(1001≤x≤1000+n) and two strings t(00:00≤t≤05:00) and s, denoting the team submits problem x at time t, and the result is s. t is in the format of HH:MM, while s is in the set {AC, PE, WA, RE, TLE, MLE, OLE}. The team is so cautious that they never submit a CE code. It is guaranteed that all the t in the input is in ascending order and every t is unique.

 

Output

For each test case, print a single line containing two integers A and B, denoting the number of problems the team passed and the penalty.

 

Sample Input

1
3 5
1002 00:02 AC
1003 00:05 WA
1003 00:06 WA
1003 00:07 AC
1002 04:59 AC

 

Sample Output

2 49

 技术分享

 Code:

技术分享
 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 static const int MAXN = 1e4 + 10;
 4 int t;
 5 int hh , mm;
 6 int n , m;
 7 bool ac[MAXN];
 8 int times[MAXN];
 9 int main()
10 {
11     scanf("%d" , &t);
12     while(t--)
13     {
14         memset(times , 0 , sizeof(times));
15         memset(ac , 0 , sizeof(ac));
16         scanf("%d%d" , &n , &m);
17         while(m--)
18         {
19             int id;
20             char cmd[15] = {\\0};
21             scanf("%d" , &id);
22             scanf("%d:%d" , &hh , &mm);
23             scanf(" %s" , cmd);
24             if(ac[id])
25             {
26                 continue;
27             }
28             if(cmd[0] == A)
29             {
30                 times[id] += (hh * 60 + mm);
31                 ac[id] = 1;
32             }
33             else
34             {
35 
36                 times[id] += 20;
37             }
38             getchar();
39         }
40         int yes = 0 , sum = 0;
41         for(int i = 1001 ; i <= 1000 + n ; ++i)
42         {
43             if(ac[i])
44             {
45                 sum += times[i];
46                 ++yes;
47             }
48         }
49         printf("%d %d\\n" , yes , sum);
50     }
51 
52 
53 }
View Code

 

C.Coprime Sequence(数论 + 前缀GCD)

Problem Description

Do you know what is called ``Coprime Sequence‘‘? That is a sequence consists of n positive integers, and the GCD (Greatest Common Divisor) of them is equal to 1.``Coprime Sequence‘‘ is easy to find because of its restriction. But we can try to maximize the GCD of these integers by removing exactly one integer. Now given a sequence, please maximize the GCD of its elements.

 

Input

The first line of the input contains an integer T(1≤T≤10), denoting the number of test cases.In each test case, there is an integer n(3≤n≤100000) in the first line, denoting the number of integers in the sequence.Then the following line consists of n integers a1,a2,...,an(1≤ai≤109), denoting the elements in the sequence.

 

Output

For each test case, print a single line containing a single integer, denoting the maximum GCD.

 

Sample Input

3
3
1 1 1
5
2 2 2 3 2
4
1 2 4 8

 

Sample Output

1
2
2

 技术分享

Code:

技术分享
 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 static const int MAXN = 1e5 + 10;
 4 int data[MAXN];
 5 int pre[MAXN];
 6 int tail[MAXN];
 7 int pos;
 8 int main()
 9 {
10     int t;
11     scanf("%d" , &t);
12     while(t--)
13     {
14         int n;
15         int ans = 0;
16         scanf("%d" , &n);
17         for(int i = 1 ; i <= n ; ++i)
18         {
19             scanf("%d" , &data[i]);
20         }
21         pre[1] = data[1];pre[0] = 0;
22         pre[2] = __gcd(data[1] , data[2]);
23         for(int i = 3 ; i <= n ; ++i)
24         {
25             pre[i] = __gcd(pre[i - 1] , data[i]);
26         }
27         tail[n] = data[n];tail[n + 1] = 0;
28         tail[n - 1] = __gcd(data[n] , data[n - 1]);
29         for(int i = n - 2 ; i > 0 ; --i)
30         {
31             tail[i] = __gcd(tail[i + 1] , data[i]);
32         }
33         for(int i = 1 ; i <= n ; ++i)
34         {
35             ans = max(ans , __gcd(pre[i - 1] , tail[i + 1]));
36         }
37         printf("%d\\n" , ans);
38     }
39 }
View Code

 

E.Easy Summation(快速幂)

Problem Description

You are encountered with a traditional problem concerning the sums of powers.Given two integers n and k. Let f(i)=ik, please evaluate the sum f(1)+f(2)+...+f(n). The problem is simple as it looks, apart from the value of n in this question is quite large.Can you figure the answer out? Since the answer may be too large, please output the answer modulo 109+7.

 

Input

The first line of the input contains an integer T(1≤T≤20), denoting the number of test cases.Each of the following T lines contains two integers n(1≤n≤10000) and k(0≤k≤5).

 

Output

For each test case, print a single line containing an integer modulo 109+7.

 

Sample Input

3
2 5
4 2
4 1

 

Sample Output

33
30
10

 技术分享

Code:

技术分享
 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 typedef long long LL;
 4 static const LL MOD = 1e9 + 7;
 5 LL n , k;
 6 LL Quick(LL a , LL b)
 7 {
 8     LL yaoyuan = 1;
 9     while(b)
10     {
11         if(b & 1)
12             yaoyuan = yaoyuan * a % MOD;
13         a = a * a % MOD;
14         b >>= 1;
15     }
16     return yaoyuan;
17 }
18 int main()
19 {
20     int t;
21     scanf("%d" , &t);
22     while(t--)
23     {
24         LL sum = 0;
25         scanf("%lld%lld" , &n , &k);
26         for(LL i = 1 ; i <= n ; ++i)
27         {
28             sum = (sum + Quick(i , k)) % MOD;
29         }
30         printf("%lld\\n" , sum);
31     }
32 }
View Code

 

以上是关于2017中国大学生程序设计竞赛 - 女生专场(重现)的主要内容,如果未能解决你的问题,请参考以下文章

"巴卡斯杯" 中国大学生程序设计竞赛 - 女生专场(重现)解题思路

2017中国大学生程序设计竞赛 - 女生专场(dp)

2017中国大学生程序设计竞赛 - 女生专场 1002 dp

2017中国大学生程序设计竞赛 - 女生专场(Graph Theory)

2017中国大学生程序设计竞赛 - 女生专场 Deleting Edges(思维+最短路)

2017中国大学生程序设计竞赛 - 女生专场 Happy Necklace(递推+矩阵快速幂)