此博客纪念今天2016中国大学生程序设计竞赛 - 网络选拔赛 三道水题。
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
Sample Output
|
#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的数比较如果大就取模,一直循环下去,这样就避免了爆炸数。
1 2 3 2
Case #1: 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); } }
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
Sample Output
|
#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循环 绝壁超时,长知识了。