2016中国大学生程序设计竞赛 - 网络选拔赛
2017-08-13 19:36
477 查看
此博客纪念今天2016中国大学生程序设计竞赛
- 网络选拔赛 三道水题。
题目的意思是给你一个数字判断是不是73和137的倍数,如果是输出YES不是输出NO。
刚开始一看数据很大,直接套大数模板,但是直接爆了,我看有人抱怨JAVA也是爆了,可能是我的板子不好,有的人大数过了,最后想起来原来做的一个题,详细看代码。
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(T≤10) indicating
the number of test cases.
Each case contains one integer n.
The next line contains n (1≤n≤10) numbers: a1,a2,...,an, (1≤ai≤100000).
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。
HDU-5842
题意:绝壁大水题,我TM天真的看着例子以为是最长递增子序列,一直WA,后来有人说水题,才仔细看了看,发现是判断字符串中有多少不同的小写字母,我丢它螺母。
- 网络选拔赛 三道水题。
HDU 5832(第一个)
A water problemTime 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(0≤N), 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 |
刚开始一看数据很大,直接套大数模板,但是直接爆了,我看有人抱怨JAVA也是爆了,可能是我的板子不好,有的人大数过了,最后想起来原来做的一个题,详细看代码。
#include<stdio.h> #include<iostream> #include <algorithm> #include<string.h> #include<math.h> #include<queue> #include<set> #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<temp;i++) { sum=(sum*10+ch[i]-'0')%mod; } if(sum==0) printf("Case #%d: YES\n",ans++); else printf("Case #%d: NO\n",ans++); } return 0; }就是取出来每个数,按照当前的大小和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(T≤10) indicating
the number of test cases.
Each case contains one integer n.
The next line contains n (1≤n≤10) numbers: a1,a2,...,an, (1≤ai≤100000).
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<stdio.h> #include<string.h> #include<stdlib.h> #include<limits.h> #include<queue> #include<math.h> #include<stack> #include<vector> #include<algorithm> 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 StringTime 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:A→B 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,(1≤T≤20). 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 |
#include<iostream> #include<stdio.h> #include<cstring> #include<algorithm> 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<temp;i++) { sum[ch[i]-'a']++; } for(int i=0;i<27;i++) { if(sum[i]) j++; } printf("Case #%d: %d\n",k,j); } return 0; }还有那个判断长度的如果放在for循环 绝壁超时,长知识了。
相关文章推荐
- HDUOJ5832A water problem&&2016中国大学生程序设计竞赛 - 网络选拔赛1001
- 2016中国大学生程序设计竞赛 - 网络选拔赛 J. Alice and Bob
- 2016中国大学生程序设计竞赛 - 网络选拔赛 1011
- HDU 5832 A water problem(简单思维题目)【2016中国大学生程序设计竞赛 - 网络选拔赛】
- 2016中国大学生程序设计竞赛 - 网络选拔赛 1004 Danganronpa hdu5835
- 2016中国大学生程序设计竞赛 - 网络选拔赛 1008 Special Tetrahedron hdu5839
- 2016中国大学生程序设计竞赛 - 网络选拔赛 1007 Mountain hdu5838
- hdu 5833 Zhu and 772002 2016中国大学生程序设计竞赛 - 网络选拔赛1002 [质因子分解+高斯消元]【数论】
- 2016中国大学生程序设计竞赛 - 网络选拔赛 题解(待续)
- HDUOJ5832Lweb and String&&2016中国大学生程序设计竞赛 - 网络选拔赛1011
- 2016中国大学生程序设计竞赛 - 网络选拔赛 A Wtaer Problem
- HDU 5833 Zhu and 772002(高斯消元)——2016中国大学生程序设计竞赛 - 网络选拔赛
- 2016中国大学生程序设计竞赛 - 网络选拔赛
- HDU 5839 Special Tetrahedron(计算几何)——2016中国大学生程序设计竞赛 - 网络选拔赛
- 2016中国大学生程序设计竞赛 - 网络选拔赛 1001 A water problem
- HDU 5832 A water problem(取模~)—— 2016中国大学生程序设计竞赛 - 网络选拔赛
- 2016中国大学生程序设计竞赛 - 网络选拔赛——题目笔记
- 2016中国大学生程序设计竞赛 - 网络选拔赛 hdu 5839 Special Tetrahedron
- HDUOJ5835Danganronpa&&2016中国大学生程序设计竞赛 - 网络选拔赛1004
- 2016中国大学生程序设计竞赛 - 网络选拔赛【三水题 1001 && 1004 && 1011】