1001 

开场白

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 12147    Accepted Submission(s): 3502


 

Problem Description

来自世界各地的年青人在 https://2050.org.cn 握手团聚, 他们是航空航天的新生代,编程大赛的优胜者,35岁以下的创新者,科技公司的创始人,展望未来的科学家,天马行空的艺术家...... TA们期待在这里与所有人分享交流,给彼此灵感,给未来答案。

我们想要用10个题目,大声喊出年青人的声音。我们希望和大家一起用技术创造一个更好的2050。

第一道题目,我们来玩一个数字游戏。
给出一个数字 n,我们想知道 n 是不是若干个 2050 依次拼接起来的。

 

 

Input

第一行一个正整数 T (T≤10) 表示数据组数。
对于每组数据,一行一个正整数 n (1≤n≤10100000)。

 

 

Output

对于每组数据,Yes 表示 n 是若干个 2050 依次拼接起来的,No 表示不是。

 

 

Sample Input


 

2 2050 205020

 

 

Sample Output


 

Yes No

水题,别忘判断是4的倍数就行。

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<set>
#include<string>
#include<cmath>
#include<cstring>
#define F first
#define S second
#define ll long long
#define pb push_back
#define pm make_pair
using namespace std;
typedef pair<int,int> PII;
const int MAX = 2e5 + 5;
char s[MAX];
char ss[5] = "2050";
int main()
{
    int n;
    int t;
    cin>>t;
    while(t--) {
        scanf("%s",s);
        int len = strlen(s);
        int flag = 1;
        if(len%4!=0) flag=0;
        for(int i = 0; i<len; i++) {
            if(s[i] != ss[i%4]) flag = 0;
        }
        if(flag) puts("Yes");
        else puts("No");
    }
    
    return 0 ;
}

 

1002

时间间隔

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 7501    Accepted Submission(s): 2735


 

Problem Description

2019年1月1日,在云栖出现了可能是全世界最长的以秒为单位的倒计时装置:九亿多秒倒计时,直到2050年。

给出一个时间S,我们想知道S距离2050年1月1日0点0时0分多少秒。

因为答案可能很大,请输出答案模100的值。

 

 

Input

第一行一个正整数 T (1≤T≤100000) 表示数据组数。

对于每组数据,一行一个字符串表示时间。
时间格式为:YYYY-MM-DD HH:MM:SS,分别表示年、月、日、时,分、秒。

输入的时间保证都在2019年1月1日以后(包含当天)。

 

 

Output

对于每组数据输出一行一个整数表示答案。

 

 

Sample Input


 

1 2019-01-01 00:00:00

 

 

Sample Output


 

0

 

 

Source


 

Test Contest

 水题,不难找出规律:每一天的秒数都是100的倍数,所以直接水题了、、不知道样例里面有没有年数大于2050的,,就都写上了。

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<set>
#include<string>
#include<cmath>
#include<cstring>
#define F first
#define S second
#define ll long long
#define pb push_back
#define pm make_pair
using namespace std;
typedef pair<int,int> PII;
const int MAX = 2e5 + 5;
char ss[MAX],qq[MAX];
int main()
{
    int n;
    int t;
    cin>>t;
    while(t--) {
        scanf("%s",qq);scanf("%s",ss);
        int year = (qq[0]-'0')*1000+(qq[1]-'0')*100+(qq[2]-'0')*10+(qq[3]-'0');
        int h = (ss[0]-'0')*10 + ss[1]-'0';
        int m = (ss[3]-'0')*10 + ss[4]-'0';
        int s = (ss[6]-'0')*10 + ss[7]-'0';
        int cur = h*60*60+m*60+s;
        if(year < 2050) printf("%d\n",(86400-cur)%100);
        else printf("%d\n",cur%100);
         
    }
    
    return 0 ;
}


1003 

分宿舍

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 5502    Accepted Submission(s): 704


 

Problem Description

“那天TA说TA要来,于是我就来啦。
那天我说我要来,于是你就来啦。
TA看到了什么?
你又看到了什么?
我看到你们在一起,我是真的很happy:)
太阳在哪里啊?
就在早上七八点。
太阳在哪里啊?
就在云的栖息地!”
——2050主题曲


2050的线下活动吸引了很多心怀梦想的年轻人。

小伙们打算组团去参加。他们一共有 n+m+2k 个人,包括 n+k 个男生,m+k 个女生,其中 k 对男女生为异性情侣,现在他们要找房间住。房间有三种类型,双人间 a 元一间,三人间 b 元一间,这两种只能同性一起住。情侣间能住一对异性情侣,一间 c 元。除了情侣间以外,其他房间都可以不住满。

求最少花多少钱,能让小伙伴们都有地方住。

 

 

Input

第一行一个整数 T (1≤T≤50) 表示数据组数。

接下来 T 组数据,每组数据一行 6 个整数 n,m,k,a,b,c,其中 0≤n,m,k≤103,0≤a,b,c≤109。

 

 

Output

对于每组数据输出一行一个数,表示所有人住下来所需要的最小花费。

 

 

Sample Input


 

2 3 0 1 1 3 3 3 3 2 1 6 2

 

 

Sample Output


 

3 6

刚开始直接感觉要么情侣全一起住,要么都不住。但是想了个样例把自己hack了,,于是老老实实写暴力、。、枚举住情侣套房的,然后再枚举用三人间的。复杂度O(n^2)。不过虽然这题是xjb搞的,,不过感觉也还是能找出规律来AC的。

AC代码:

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<set>
#include<string>
#include<cmath>
#include<cstring>
#define F first
#define S second
#define ll long long
#define pb push_back
#define pm make_pair
using namespace std;
typedef pair<int,int> PII;
const int MAX = 2e5 + 5;
ll n,m,k,a,b,c;
ll so(ll N,ll M,ll ql) {
    ll res1 = 1e14,res2 = 1e14;
    ll up = N/3;
    if(N%3 != 0) up++;
    ll tmp = 0;
    for(ll i = 0; i<=up; i++) {
        tmp = b*i;
        ll sheng = i*3;
        sheng = N - sheng;
        if(sheng>0) tmp += (sheng+1)/2*a;
        res1 = min(res1,tmp);
    }
    up = M/3;
    if(M%3!=0) up++;
    tmp = 0;
    for(ll i = 0; i<=up; i++) {
        tmp = b*i;
        ll sheng = i*3;
        sheng = M-sheng;
        if(sheng>0) tmp += (sheng+1)/2*a;
        res2 = min(res2,tmp);
    }
    return res1+res2+ql*c;
}
int main()
{
    int t;
    cin>>t;
    while(t--) {
        scanf("%lld%lld%lld%lld%lld%lld",&n,&m,&k,&a,&b,&c);
        ll ans = LLONG_MAX;
        for(ll i = 0; i<=k; i++) {
            ans = min(ans,so(n+k-i,m+k-i,i));
        }
        printf("%lld\n",ans);
    }
    
    return 0 ;
}

1004.

PASS

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 5635    Accepted Submission(s): 2957


 

Problem Description

有 n 个选手参加了 2050 编程竞赛,他们属于 m 个学校,学校的编号为 1 到 m,2050 编程竞赛的 PASS 奖励资格如下:对于一个学校,如果它有 x 个学生参赛,它的参赛学生里成绩最好的 ⌊xk⌋ 人里,每有一个人总排名在前 50% 内(包括50%),就奖励一个 PASS。

现在给出每个选手所属的学校和它的排名(假设没有平手),请你帮主办方算一下一共发出了几个 PASS。

 

 

Input

第一行一个正整数 T (1≤T≤10) 表示数据组数。

接下来 T 组数据,对于每组数据:

第一行三个正整数 n,m,k (1≤n≤104,1≤m≤103,2≤k≤20)。

第二行 n 个数,按照成绩从好到差给出 n 个选手所属的学校。

 

 

Output

对于每组数据输出一行一个整数表示答案。

 

 

Sample Input


 

2 6 2 2 1 1 2 1 2 2 8 2 2 1 1 2 1 2 2 2 2

 

 

Sample Output


 

2 2

模拟就好了。

AC代码:

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<set>
#include<string>
#include<cmath>
#include<cstring>
#define F first
#define S second
#define ll long long
#define pb push_back
#define pm make_pair
using namespace std;
typedef pair<int,int> PII;
const int MAX = 2e4 + 5;
int n,m,k;
int a[MAX];
int rk[MAX];//rk[i]第i个学校可以得到的名额 
int now[MAX];//第i个学校已经得到的名额 
int cnt[MAX];//属于第i个学校的人数 
int main()
{
    int t;
    cin>>t;
    while(t--) {
        scanf("%d%d%d",&n,&m,&k);
        memset(now,0,sizeof now);
        memset(cnt,0,sizeof cnt);
        for(int i = 1; i<=n; i++) scanf("%d",a+i),cnt[a[i]]++;
        for(int i = 1; i<=m; i++) rk[i] = cnt[i]/k;
        int up = n/2,ans = 0;
        for(int i = 1; i<=up; i++) {
            if(now[a[i]] < rk[a[i]]) ans++,now[a[i]]++;
        }
        printf("%d\n",ans);
    }
    
    return 0 ;
}

 


 1005。

球赛

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1872    Accepted Submission(s): 111


 

Problem Description

https://2050.org.cn/games-at2019 是2050非常重要的组成部分之一,包括逐日晨跑、足球风暴、室内骑行挑战、棒球全民打、篮球嘉年华、户外电影等活动。

身体是革命的本钱,这道题是关于运动的。
Alice和Bob在进行乒乓球比赛,比赛一共打了 n 个球,对于每一球,如果Alice赢了,那么裁判员会在计分板上记下'A',如果Bob赢了则会记下'B'。
时间转眼间到了2050年,计分板上某些信息因为时间流逝丢失了,但我们想要复现当年的激烈局面。
丢失的位置用'?'表示,我们想知道,计分板上对应的乒乓球球赛,最多进行了多少局(最后一局可以没打完,但是如果没打完的话就不计入答案)?
在一局比赛中,先得11分的一方为胜方,10平后,先多得2分的一方为胜方。

 

 

Input

第一行一个整数 T (1≤T≤51) 表示数据组数。

接下来 T 组数据,每行一个字符串表示计分板上记录的信息,计分板上只包含'A','B','?'这些字符,计分板长度 n≤10000。

 

 

Output

对于每组数据输出一行一个数,表示乒乓球球赛最多进行的局数。

 

 

Sample Input


 

1 AAAAAAAAAA?BBBBBBBBBB?

 

 

Sample Output


 

2

不会dp。


1006。

冰水挑战

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2397    Accepted Submission(s): 429


 

Problem Description

Polar Bear Pitching helps you crystallize your message. 
The stage could not be any cooler, and we mean literally: 
a hole cut through the ice in the frozen Baltic Sea.

2050有一项很有挑战的活动 —— Polar Bear Pitching 。
体验人跳入冰水中讲述自己的恐惧,改变以及梦想。这是没有时间限制的演讲,就看你能在冰水中呆多久!

现在,我们要依次面对 n 个冰水挑战,每个挑战你都可以选择接受或不接受。接受第 i 个挑战会让你丧失 ai点体力,因为每个挑战所处的环境不同,如果你要挑战它,在挑战它之前你的体力 x 会变成 min(x,bi),当你完成这个挑战的时候,你的体力会变成 x−ai,体力任何时候不允许小于等于 0,无论你是否接受第 i 个挑战,在这个挑战结束以后你的体力都会增加 ci。

现在我们想知道最多可以完成多少个挑战。

 

 

Input

第一行一个正整数 T (T≤50) 表示数据组数。

接下来 T 组数据,每组第一行两个正整数 n,c (1≤n≤103,1≤c≤109),表示挑战的数量和初始体力,接下来 n 行,每行三个非负整数 ai,bi,ci(0≤ai,bi,ci≤109)。

 

 

Output

对于每组数据输出一行一个数,表示你最多能完成几个挑战。

 

 

Sample Input


 

2 3 10 1 2 0 4 8 3 6 10 1 2 1 1 1 1 1 1 1

 

 

Sample Output


 

2 0

 刚开始定义状态定义错了,所以一直挂机3小时。

WA代码:

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<set>
#include<string>
#include<cmath>
#include<cstring>
#define F first
#define S second
#define ll long long
#define pb push_back
#define pm make_pair
using namespace std;
typedef pair<int,int> PII;
const int MAX = 2e3 + 5;
int n;
ll a[MAX],b[MAX],c[MAX];
ll C;
ll dp[MAX];//个数 
ll dpc[MAX];//截止 挑战后(加ci了) 的体力最大值 
ll sum[MAX];
int main()
{
    int t;
    cin>>t;
    while(t--) {
        scanf("%d%lld",&n,&C);
        memset(dp,0,sizeof dp);
        memset(dpc,0,sizeof dpc);
        for(int i = 1; i<=n; i++) scanf("%lld%lld%lld",a+i,b+i,c+i),sum[i] = sum[i-1] + c[i];
        for(int i = 1; i<=n; i++) {
            for(int j = 0; j<=i-1; j++) {
                ll tmpc;
                if(j != 0) tmpc = min(b[i],dpc[j] + sum[i-1] - sum[j]) - a[i];
                else tmpc = min(C + sum[i-1],b[i]) - a[i];
                if(tmpc > 0) {
                    if(dp[i] < dp[j]+1) {
                        dp[i] = dp[j]+1;
                        dpc[i] = tmpc + c[i];
                    }    
                    else if(dp[i] == dp[j]+1) {
                        dpc[i] = max(dpc[i],tmpc + c[i]);
                    }
                }
            }
        }
        
        printf("%lld\n",*max_element(dp+1,dp+n+1));
    }    
    return 0 ;
}

然后贴一发不知道AC与否的代码:(比赛结束后仓促的写的代码,,暂时找不到地方提交)(找到地方交了,2e3MLE了,改成1e3过了)

dp[i][j]代表前i个挑战我参与了j个的最大体力值。

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<set>
#include<string>
#include<cmath>
#include<cstring>
#define F first
#define S second
#define ll long long
#define pb push_back
#define pm make_pair
using namespace std;
typedef pair<int,int> PII;
const int MAX = 2e3 + 5;
int n;
ll a[MAX],b[MAX],c[MAX];
ll C;
ll dp[MAX][MAX];
bool ok[MAX][MAX];
ll sum[MAX];
int main()
{
	int t;
	cin>>t;
	while(t--) {
		scanf("%d%lld",&n,&C);
		memset(dp,0,sizeof dp);
		memset(ok,0,sizeof ok);
		ok[0][0] = 1;
		dp[0][0] = C;
		for(int i = 1; i<=n; i++) scanf("%lld%lld%lld",a+i,b+i,c+i),sum[i] = sum[i-1] + c[i];
		for(int i = 1; i<=n; i++) {
			for(int j = 0; j<=i; j++) {
				if(ok[i-1][j] == 1) dp[i][j] = dp[i-1][j] + c[i],ok[i][j] = 1;
				ll tmpc = min(b[i],dp[i-1][j-1])-a[i];
				if(tmpc > 0) {
					dp[i][j] = max(dp[i][j],tmpc + c[i]);
					if(ok[i-1][j-1] == 1) ok[i][j] = 1; 
				}
			}
		}
		ll ans = 0;
		for(int i = 1; i<=n; i++) {
			if(ok[n][i] > 0) ans = max(ans,1LL * i);
		}
		printf("%lld\n",ans);
	}
	return 0 ;
}

1007

大厦

Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 257    Accepted Submission(s): 86


 

Problem Description

现在就让我们来大胆地畅想2050。我们乘坐着无人驾驶的飞行汽车,驰骋在城市的街头,感受着都市的繁华。

我们看到了一栋高楼大厦,大厦的墙面可以看做一个 W×H 的矩形,我们把它的左下角当成(0,0),右上角当成(W,H)。上面分布着一些LED灯,这些LED灯与地面呈45度倾斜,并且从矩形的边界延伸到另一边界,把大厦分成了若干个区域。我们想数一下这个图里面存在多少个与地面成45度角的矩形,其中四条边都是LED灯的一部分。

 

 

Input

第一行一个正整数 T (T≤10) 表示数据组数。
对于每组数据,第一行 W,H,n,m (1≤W,H≤109,0≤n,m≤103) 表示矩形的长和宽,以及两种方向的LED灯的个数。
接下来一行 n 个整数c (1≤c≤W+H−1),表示这个LED灯可以表示成 x+y=c 的形式,保证 c 两两不同。
接下来一行 m 个整数 c (1−H≤c≤W−1),表示这个LED灯可以表示成 x−y=c 的形式,保证 c 两两不同。

 

 

Output

对于每组数据,输出一个整数表示答案,由于答案可能很大,对 109+7 取模。

 

 

Sample Input


 

1 21 12 6 5 4 8 14 20 26 30 -6 -1 2 10 14

 

 

Sample Output


 

19