2016中国大学生程序设计竞赛 - 网络选拔赛

此博客纪念今天2016中国大学生程序设计竞赛 - 网络选拔赛 三道水题。

HDU 5832(第一个)



A water problem

Time Limit: 5000/2500 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 2871    Accepted Submission(s): 1034


Problem Description
Two planets named Haha and Xixi in the universe and they were created with the universe beginning.

There is  73  days in Xixi a year and  137  days in Haha a year. 

Now you know the days  N  after Big Bang, you need to answer whether it is the first day in a year about the two planets.
 

Input
There are several test cases(about  5  huge test cases).

For each test, we have a line with an only integer  N(0N) , the length of  N  is up to  10000000 .
 

Output
For the i-th test case, output Case #i: , then output "YES" or "NO" for the answer.
 

Sample Input
         
           
           
           
           
10001 0 333
 

Sample Output
         
           
           
           
           
Case #1: YES Case #2: YES Case #3: NO
题目的意思是给你一个数字判断是不是73和137的倍数,如果是输出YES不是输出NO。
刚开始一看数据很大,直接套大数模板,但是直接爆了,我看有人抱怨JAVA也是爆了,可能是我的板子不好,有的人大数过了,最后想起来原来做的一个题,详细看代码。

#include
#include 
#include 
#include
#include
#include
#include
#define LL long long
#define s(n) scanf("%d",&n)
#define p(n) printf("%d\n",n)
#define mod 10001
using namespace std;
char ch[10000005];
int main()
{
	int T,ans=1;
	while(scanf("%s",&ch)!=EOF)
	{	
		int temp=strlen(ch);
		int sum=0;
		for(int i=0;i
就是取出来每个数,按照当前的大小和Mod的数比较如果大就取模,一直循环下去,这样就避免了爆炸数。

hdu 5835

Danganronpa

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 914    Accepted Submission(s): 620


Problem Description
Chisa Yukizome works as a teacher in the school. She prepares many gifts, which consist of  n  kinds with  a[i]  quantities of each kind, for her students and wants to hold a class meeting. Because of the busy work, she gives her gifts to the monitor, Chiaki Nanami. Due to the strange design of the school, the students' desks are in a row. Chiaki Nanami wants to arrange gifts like this:

1. Each table will be prepared for a mysterious gift and an ordinary gift.

2. In order to reflect the Chisa Yukizome's generosity, the kinds of the ordinary gift on the adjacent table must be different.

3. There are no limits for the mysterious gift.

4. The gift must be placed continuously.

She wants to know how many students can get gifts in accordance with her idea at most (Suppose the number of students are infinite). As the most important people of her, you are easy to solve it, aren't you?
 

Input
The first line of input contains an integer  T(T10)  indicating the number of test cases.

Each case contains one integer  n . The next line contains  n   (1n10)  numbers:  a1,a2,...,an (1ai100000) .
 

Output
For each test case, output one line containing “Case #x: y” (without quotes) , where x is the test case number (starting from 1) and y is the answer of Chiaki Nanami's question.
 

Sample Input
     
       
       
       
       
1 2 3 2
 

Sample Output
     
       
       
       
       
Case #1: 2
题解:
本题无非两种情况
(1)最大的大于剩下的总和,此时肯定是(sum-max)*2+1。最大的其余的插空放 最后用最大的封顶。
(2)最大的小于剩下的总和,这是不足的需要后面的来补,答案肯定是sum/2。
#include  
#include  
#include  
#include  
#include  
#include  
#include  
#include  
#include  
using namespace std;  
#define maxn  100005  
int a[maxn];  
int  main()  
{  
    int T,i,sum,ans,maxs,n,cases=0;  
    scanf("%d",&T);  
    while(T--)  
    {  
        maxs=0;sum=0;  
        scanf("%d",&n);  
        for(i=1;i<=n;i++)  
        {  
            scanf("%d",&a[i]);  
            sum+=a[i];  
            maxs=max(maxs,a[i]);  
        }  
        int ans=min(sum/2,(sum-maxs)*2+1);  
        printf("Case #%d: %d\n",++cases,ans);  
    }  
}  


HDU-5842

Lweb and String

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 1151    Accepted Submission(s): 602


Problem Description
Lweb has a string  S .

Oneday, he decided to transform this string to a new sequence. 

You need help him determine this transformation to get a sequence which has the longest LIS(Strictly Increasing). 

You need transform every letter in this string to a new number.

A  is the set of letters of  S B  is the set of natural numbers. 

Every injection  f:AB  can be treat as an legal transformation. 

For example, a String “aabc”,  A={a,b,c} , and you can transform it to “1 1 2 3”, and the LIS of the new sequence is 3. 

Now help Lweb, find the longest LIS which you can obtain from  S .

LIS: Longest Increasing Subsequence. (https://en.wikipedia.org/wiki/Longest_increasing_subsequence)
 

Input
The first line of the input contains the only integer  T,(1T20) .

Then  T  lines follow, the i-th line contains a string  S  only containing the lowercase letters, the length of  S  will not exceed  105 .
 

Output
For each test case, output a single line "Case #x: y", where x is the case number, starting from 1. And y is the answer.
 

Sample Input
         
           
           
           
           
2 aabcc acdeaa
 

Sample Output
         
           
           
           
           
Case #1: 3 Case #2: 4
题意:绝壁大水题,我TM天真的看着例子以为是最长递增子序列,一直WA,后来有人说水题,才仔细看了看,发现是判断字符串中有多少不同的小写字母,我丢它螺母。
#include
#include
#include  
#include  
using namespace std;  
char ch[100005];
int sum[30];  
int main()  
{  
    int n;  
    scanf("%d",&n);  
    for(int k=1;k<=n;k++) 
    {  
        int len,i,j=0;  
        scanf("%s",ch);  
        int temp=strlen(ch);
        memset(sum,0,sizeof(sum));
        for(int i=0;i
还有那个判断长度的如果放在for循环 绝壁超时,长知识了。



你可能感兴趣的:(水题)