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 }

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 }

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 }

时间: 2024-11-04 11:31:27

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

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

Building Shops Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) Total Submission(s): 701 Accepted Submission(s): 265 Problem Description HDU's n classrooms are on a line ,which can be considered as a number line. Eac

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

Happy Necklace Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 1146    Accepted Submission(s): 491 Problem Description Little Q wants to buy a necklace for his girlfriend. Necklaces are single

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

Deleting Edges Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 567    Accepted Submission(s): 210 Problem Description Little Q is crazy about graph theory, and now he creates a game about grap

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

Building Shops Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 0    Accepted Submission(s): 0 Problem Description HDU’s n classrooms are on a line ,which can be considered as a number line. Ea

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

此文章可以使用目录功能哟↑(点击上方[+]) 经过这么一次女生赛,告诉我们千万不要小瞧女生,不然会死得很惨,orz... 链接→"巴卡斯杯" 中国大学生程序设计竞赛 - 女生专场(重现)  Problem 1001 Solving Order Accept: 0    Submit: 0 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit : 32768/32768 K (Java/Others)  Problem Descri

HDU 6024(中国大学生程序设计竞赛女生专场1002)

这是CCPC女生专场的一道dp题.大佬们都说它简单,我并没有感到它有多简单. 先说一下题意:在一条直线上,有n个教室,现在我要在这些教室里从左到右地建设一些作为糖果屋,每个教室都有自己的坐标xi 和建造糖果屋的费用ci , 如果在这里建造一个糖果屋,那么花费ci ,如果不建造糖果屋,则花费是当前教室的坐标与左边最靠近当前教室的糖果屋坐标之差,问最小花费. 一看这是个求最优解的问题,应该明白这是个dp问题,现在来考虑该问题状态的定义: 当我建设到第i个教室的时候,我有两种选择,建糖果屋或者不建糖果

Permutation-水题-2017中国大学生程序设计竞赛-哈尔滨站-重现赛

Permutation Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 0    Accepted Submission(s): 0Special Judge Problem Description A permutation p1,p2,...,pn of 1,2,...,n is called a lucky permutatio

A Simple Stone Game-找素因子(欧拉函数)-2017中国大学生程序设计竞赛-哈尔滨站-重现赛

A Simple Stone Game Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 0    Accepted Submission(s): 0 Problem Description After he has learned how to play Nim game, Bob begins to try another ston

&quot;巴卡斯杯&quot; 中国大学生程序设计竞赛 - 女生专场

Combine String #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #include<cmath> #include<queue> #include<vector> #include<map> using namespace std; typedef unsigned long long LL; #de