【2050 Programming Competition - 2050 一万人码 】非官方部分题解(HDU)
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 握手團聚, 他們是航空航天的新生代,編程大賽的優(yōu)勝者,35歲以下的創(chuàng)新者,科技公司的創(chuàng)始人,展望未來的科學家,天馬行空的藝術家...... TA們期待在這里與所有人分享交流,給彼此靈感,給未來答案。
我們想要用10個題目,大聲喊出年青人的聲音。我們希望和大家一起用技術創(chuàng)造一個更好的2050。
第一道題目,我們來玩一個數(shù)字游戲。
給出一個數(shù)字?n,我們想知道?n?是不是若干個 2050 依次拼接起來的。
?
?
Input
第一行一個正整數(shù)?T?(T≤10)?表示數(shù)據(jù)組數(shù)。
對于每組數(shù)據(jù),一行一個正整數(shù)?n?(1≤n≤10100000)。
?
?
Output
對于每組數(shù)據(jù),Yes 表示?n?是若干個 2050 依次拼接起來的,No 表示不是。
?
?
Sample Input
?2 2050 205020
?
?
Sample Output
?Yes No
水題,別忘判斷是4的倍數(shù)就行。
#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日,在云棲出現(xiàn)了可能是全世界最長的以秒為單位的倒計時裝置:九億多秒倒計時,直到2050年。
給出一個時間S,我們想知道S距離2050年1月1日0點0時0分多少秒。
因為答案可能很大,請輸出答案模100的值。
?
?
Input
第一行一個正整數(shù)?T?(1≤T≤100000)?表示數(shù)據(jù)組數(shù)。
對于每組數(shù)據(jù),一行一個字符串表示時間。
時間格式為:YYYY-MM-DD HH:MM:SS,分別表示年、月、日、時,分、秒。
輸入的時間保證都在2019年1月1日以后(包含當天)。
?
?
Output
對于每組數(shù)據(jù)輸出一行一個整數(shù)表示答案。
?
?
Sample Input
?1 2019-01-01 00:00:00
?
?
Sample Output
?0
?
?
Source
?Test Contest
?水題,不難找出規(guī)律:每一天的秒數(shù)都是100的倍數(shù),所以直接水題了、、不知道樣例里面有沒有年數(shù)大于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?對男女生為異性情侶,現(xiàn)在他們要找房間住。房間有三種類型,雙人間?a?元一間,三人間?b?元一間,這兩種只能同性一起住。情侶間能住一對異性情侶,一間?c?元。除了情侶間以外,其他房間都可以不住滿。
求最少花多少錢,能讓小伙伴們都有地方住。
?
?
Input
第一行一個整數(shù)?T?(1≤T≤50)?表示數(shù)據(jù)組數(shù)。
接下來?T?組數(shù)據(jù),每組數(shù)據(jù)一行?6?個整數(shù)?n,m,k,a,b,c,其中?0≤n,m,k≤103,0≤a,b,c≤109。
?
?
Output
對于每組數(shù)據(jù)輸出一行一個數(shù),表示所有人住下來所需要的最小花費。
?
?
Sample Input
?2 3 0 1 1 3 3 3 3 2 1 6 2
?
?
Sample Output
?3 6
剛開始直接感覺要么情侶全一起住,要么都不住。但是想了個樣例把自己hack了,,于是老老實實寫暴力、。、枚舉住情侶套房的,然后再枚舉用三人間的。復雜度O(n^2)。不過雖然這題是xjb搞的,,不過感覺也還是能找出規(guī)律來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%?內(nèi)(包括50%),就獎勵一個 PASS。
現(xiàn)在給出每個選手所屬的學校和它的排名(假設沒有平手),請你幫主辦方算一下一共發(fā)出了幾個 PASS。
?
?
Input
第一行一個正整數(shù)?T?(1≤T≤10)?表示數(shù)據(jù)組數(shù)。
接下來?T?組數(shù)據(jù),對于每組數(shù)據(jù):
第一行三個正整數(shù)?n,m,k?(1≤n≤104,1≤m≤103,2≤k≤20)。
第二行?n?個數(shù),按照成績從好到差給出?n?個選手所屬的學校。
?
?
Output
對于每組數(shù)據(jù)輸出一行一個整數(shù)表示答案。
?
?
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個學校已經(jīng)得到的名額 int cnt[MAX];//屬于第i個學校的人數(shù) 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非常重要的組成部分之一,包括逐日晨跑、足球風暴、室內(nèi)騎行挑戰(zhàn)、棒球全民打、籃球嘉年華、戶外電影等活動。
身體是革命的本錢,這道題是關于運動的。
Alice和Bob在進行乒乓球比賽,比賽一共打了?n?個球,對于每一球,如果Alice贏了,那么裁判員會在計分板上記下'A',如果Bob贏了則會記下'B'。
時間轉(zhuǎn)眼間到了2050年,計分板上某些信息因為時間流逝丟失了,但我們想要復現(xiàn)當年的激烈局面。
丟失的位置用'?'表示,我們想知道,計分板上對應的乒乓球球賽,最多進行了多少局(最后一局可以沒打完,但是如果沒打完的話就不計入答案)?
在一局比賽中,先得11分的一方為勝方,10平后,先多得2分的一方為勝方。
?
?
Input
第一行一個整數(shù)?T?(1≤T≤51)?表示數(shù)據(jù)組數(shù)。
接下來?T?組數(shù)據(jù),每行一個字符串表示計分板上記錄的信息,計分板上只包含'A','B','?'這些字符,計分板長度?n≤10000。
?
?
Output
對于每組數(shù)據(jù)輸出一行一個數(shù),表示乒乓球球賽最多進行的局數(shù)。
?
?
Sample Input
?1 AAAAAAAAAA?BBBBBBBBBB?
?
?
Sample Output
?2
不會dp。
1006。
冰水挑戰(zhàn)
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有一項很有挑戰(zhàn)的活動 —— Polar Bear Pitching 。
體驗人跳入冰水中講述自己的恐懼,改變以及夢想。這是沒有時間限制的演講,就看你能在冰水中呆多久!
現(xiàn)在,我們要依次面對?n?個冰水挑戰(zhàn),每個挑戰(zhàn)你都可以選擇接受或不接受。接受第?i?個挑戰(zhàn)會讓你喪失?ai點體力,因為每個挑戰(zhàn)所處的環(huán)境不同,如果你要挑戰(zhàn)它,在挑戰(zhàn)它之前你的體力?x?會變成?min(x,bi),當你完成這個挑戰(zhàn)的時候,你的體力會變成?x?ai,體力任何時候不允許小于等于?0,無論你是否接受第?i?個挑戰(zhàn),在這個挑戰(zhàn)結(jié)束以后你的體力都會增加?ci。
現(xiàn)在我們想知道最多可以完成多少個挑戰(zhàn)。
?
?
Input
第一行一個正整數(shù)?T?(T≤50)?表示數(shù)據(jù)組數(shù)。
接下來?T?組數(shù)據(jù),每組第一行兩個正整數(shù)?n,c?(1≤n≤103,1≤c≤109),表示挑戰(zhàn)的數(shù)量和初始體力,接下來?n?行,每行三個非負整數(shù)?ai,bi,ci(0≤ai,bi,ci≤109)。
?
?
Output
對于每組數(shù)據(jù)輸出一行一個數(shù),表示你最多能完成幾個挑戰(zhàn)。
?
?
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
?剛開始定義狀態(tài)定義錯了,所以一直掛機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];//個數(shù) ll dpc[MAX];//截止 挑戰(zhàn)后(加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 ; }然后貼一發(fā)不知道AC與否的代碼:(比賽結(jié)束后倉促的寫的代碼,,暫時找不到地方提交)(找到地方交了,2e3MLE了,改成1e3過了)
dp[i][j]代表前i個挑戰(zhàn)我參與了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
現(xiàn)在就讓我們來大膽地暢想2050。我們乘坐著無人駕駛的飛行汽車,馳騁在城市的街頭,感受著都市的繁華。
我們看到了一棟高樓大廈,大廈的墻面可以看做一個?W×H?的矩形,我們把它的左下角當成(0,0),右上角當成(W,H)。上面分布著一些LED燈,這些LED燈與地面呈45度傾斜,并且從矩形的邊界延伸到另一邊界,把大廈分成了若干個區(qū)域。我們想數(shù)一下這個圖里面存在多少個與地面成45度角的矩形,其中四條邊都是LED燈的一部分。
?
?
Input
第一行一個正整數(shù)?T?(T≤10)?表示數(shù)據(jù)組數(shù)。
對于每組數(shù)據(jù),第一行?W,H,n,m?(1≤W,H≤109,0≤n,m≤103)?表示矩形的長和寬,以及兩種方向的LED燈的個數(shù)。
接下來一行?n?個整數(shù)c?(1≤c≤W+H?1),表示這個LED燈可以表示成?x+y=c?的形式,保證?c?兩兩不同。
接下來一行?m?個整數(shù)?c?(1?H≤c≤W?1),表示這個LED燈可以表示成?x?y=c?的形式,保證?c?兩兩不同。
?
?
Output
對于每組數(shù)據(jù),輸出一個整數(shù)表示答案,由于答案可能很大,對?109+7?取模。
?
?
Sample Input
?1 21 12 6 5 4 8 14 20 26 30 -6 -1 2 10 14
?
?
Sample Output
?19
總結(jié)
以上是生活随笔為你收集整理的【2050 Programming Competition - 2050 一万人码 】非官方部分题解(HDU)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: wingate.exe - wingat
- 下一篇: 拼多多电脑网页版上线:微信扫一扫就能下单