"虹软杯" 中国大学生程序设计竞赛 (杭州赛区)-网络赛水题题解

本次网络赛四大水题:

HDU5832 A water problem

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

大数取余模板题

HDU5833
Zhu and 772002

Problem Description
Zhu and 772002 are both good at math. One day, Zhu wants to test the ability of 772002, so he asks 772002 to solve a math problem.

But 772002 has a appointment with his girl friend. So 772002 gives this problem to you.

There are n numbers a1,a2,...,an. The value of the prime factors of each number does not exceed 2000 , you can choose at least one number and multiply them, then you can get a number b .

How many different ways of choices can make b is a perfect square number. The answer maybe too large, so you should output the answer modulo by 1000000007 .

Input
First line is a positive integer T , represents there are T test cases.

For each test case:

First line includes a number n(1n300) ,next line there are n numbers a1,a2,...,an,(1ai1018).

Output
For the i-th test case , first output Case #i: in a single line.

Then output the answer of i-th test case modulo by 1000000007 .

Sample Input
2
3
3 3 4
3
2 2 2

Sample Output
Case #1:
3
Case #2:
3

详细见 UVa11542,注意结果会超long long,需要循环取余。

HDU5842 Lweb and String

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

只需要记一下不相同的字母有多少个即可

Danganronpa

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

#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
using namespace std;
typedef long long LL;
const int maxn = 100007;
int kase, T = 0, a[15], n, ans;
int main() {
    scanf("%d", &kase);
    while(kase--) {
        int ans = 0;
        scanf("%d", &n);
        for(int i = 0; i < n; ++i)
            scanf("%d", &a[i]);
        int cnt = a[0];
        for(int i = 1; i < n; ++i) {
            ans += min(cnt, a[i])*2;
            cnt = abs(cnt-a[i]);
        }
        if(cnt>0) ans++,cnt--;
        if(ans>=cnt) ans = (ans+cnt)/2;
        printf("Case #%d: %d\n", ++T, ans);
    }
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

JalexDooo

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值