日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

青岛农业大学第九届ACM程序设计竞赛

發布時間:2024/10/5 编程问答 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 青岛农业大学第九届ACM程序设计竞赛 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

Problem A?喆神裝書

https://ac.nowcoder.com/acm/contest/906/A

題意:是否能夠把所有的書都放在兩個背包里。

題解:貪心

C++版本一

/* *@Author: STZG *@Language: C++ */ #include <bits/stdc++.h> #include<iostream> #include<algorithm> #include<cstdlib> #include<cstring> #include<cstdio> #include<string> #include<vector> #include<bitset> #include<queue> #include<deque> #include<stack> #include<cmath> #include<list> #include<map> #include<set> //#define DEBUG #define RI register int #define endl "\n" using namespace std; typedef long long ll; //typedef __int128 lll; const int N=100000+10; const int M=100000+10; const int MOD=1e9+7; const double PI = acos(-1.0); const double EXP = 1E-8; const int INF = 0x3f3f3f3f; int t,n,m,k,p,l,r,u,v; int ans,cnt,flag,temp,sum; int a[N]; char str; struct node{}; int main() { #ifdef DEBUGfreopen("input.in", "r", stdin);//freopen("output.out", "w", stdout); #endif//ios::sync_with_stdio(false);//cin.tie(0);//cout.tie(0);//scanf("%d",&t);//while(t--){scanf("%d",&n);for(int i=1;i<=n;i++)scanf("%d",&a[i]),sum+=a[i];for(int i=1;i<=n;i++)scanf("%d",&a[i]);sort(a+1,a+n+1);if(n>=1)ans=a[n-1]+a[n];cout<<(ans>=sum?"YES":"NO")<<endl;//}#ifdef DEBUGprintf("Time cost : %lf s\n",(double)clock()/CLOCKS_PER_SEC); #endif//cout << "Hello world!" << endl;return 0; }

Problem B?何時收錢

https://ac.nowcoder.com/acm/contest/906/B

題意:如果今年是閏年,那么收的錢是平年的兩倍,為了有更好的規劃,她想知道包括今年在內的連續兩年的收的錢是多少?

題解:

C++版本一

/* *@Author: STZG *@Language: C++ */ #include <bits/stdc++.h> #include<iostream> #include<algorithm> #include<cstdlib> #include<cstring> #include<cstdio> #include<string> #include<vector> #include<bitset> #include<queue> #include<deque> #include<stack> #include<cmath> #include<list> #include<map> #include<set> //#define DEBUG #define RI register int #define endl "\n" using namespace std; typedef long long ll; //typedef __int128 lll; const int N=100000+10; const int M=100000+10; const int MOD=1e9+7; const double PI = acos(-1.0); const double EXP = 1E-8; const int INF = 0x3f3f3f3f; int t,n,m,k,p,l,r,u,v; int ans,cnt,flag,temp,sum; int a[N]; char str; struct node{}; bool check(int x){return (x%4==0&&x%100!=0)||x%400==0; } int main() { #ifdef DEBUGfreopen("input.in", "r", stdin);//freopen("output.out", "w", stdout); #endif//ios::sync_with_stdio(false);//cin.tie(0);//cout.tie(0);//scanf("%d",&t);//while(t--){//scanf("%d",&n);scanf("%d%d",&n,&m);if(check(n)){ans=m+m/2;}else{if(check(n+1)) ans=m+m*2;else ans=m+m;}cout<<ans<<endl;//}#ifdef DEBUGprintf("Time cost : %lf s\n",(double)clock()/CLOCKS_PER_SEC); #endif//cout << "Hello world!" << endl;return 0; }

Problem C?找出叛徒

https://ac.nowcoder.com/acm/contest/906/C

題意:一個非空整數數組,除了某個元素只出現一次以外,其余每個元素均出現了三次。輸出那個只出現了一次的元素。

題解:貪心

C++版本一

/* *@Author: STZG *@Language: C++ */ #include <bits/stdc++.h> #include<iostream> #include<algorithm> #include<cstdlib> #include<cstring> #include<cstdio> #include<string> #include<vector> #include<bitset> #include<queue> #include<deque> #include<stack> #include<cmath> #include<list> #include<map> #include<set> //#define DEBUG #define RI register int #define endl "\n" using namespace std; typedef long long ll; //typedef __int128 lll; const int N=100000+10; const int M=100000+10; const int MOD=1e9+7; const double PI = acos(-1.0); const double EXP = 1E-8; const int INF = 0x3f3f3f3f; int t,n,m,k,p,l,r,u,v; int ans,cnt,flag,temp,sum; int a[N]; char str; struct node{}; int main() { #ifdef DEBUGfreopen("input.in", "r", stdin);//freopen("output.out", "w", stdout); #endif//ios::sync_with_stdio(false);//cin.tie(0);//cout.tie(0);//scanf("%d",&t);//while(t--){scanf("%d",&n);for(int i=1;i<=n;i++)scanf("%d",&t),a[t]++;for(int i=0;i<=1000;i++)if(a[i]==1)ans=i;cout<<ans<<endl;//}#ifdef DEBUGprintf("Time cost : %lf s\n",(double)clock()/CLOCKS_PER_SEC); #endif//cout << "Hello world!" << endl;return 0; }

Problem D?群神瘋了

https://ac.nowcoder.com/acm/contest/906/D

題意:
一個整數序列 1 ,2 ,... , n。她必須把它分成兩個集合A和B,每個元素恰好屬于一個集合,且令| sum(A)- sum(B) | 最小。
| x | 是x的絕對值,sum(A)是集合A的元素之和。

題解:貪心+思維

C++版本一

/* *@Author: STZG *@Language: C++ */ #include <bits/stdc++.h> #include<iostream> #include<algorithm> #include<cstdlib> #include<cstring> #include<cstdio> #include<string> #include<vector> #include<bitset> #include<queue> #include<deque> #include<stack> #include<cmath> #include<list> #include<map> #include<set> //#define DEBUG #define RI register int #define endl "\n" using namespace std; typedef long long ll; //typedef __int128 lll; const int N=100000+10; const int M=100000+10; const int MOD=1e9+7; const double PI = acos(-1.0); const double EXP = 1E-8; const int INF = 0x3f3f3f3f; int t,n,m,k,p,l,r,u,v; int ans,cnt,flag,temp,sum; int a[N]; char str; struct node{}; int main() { #ifdef DEBUGfreopen("input.in", "r", stdin);//freopen("output.out", "w", stdout); #endif//ios::sync_with_stdio(false);//cin.tie(0);//cout.tie(0);//scanf("%d",&t);//while(t--){scanf("%d",&n);if(n%4==0)ans=0;if(n%4==1)ans=1;if(n%4==2)ans=1;if(n%4==3)ans=0;cout<<ans<<endl;//}#ifdef DEBUGprintf("Time cost : %lf s\n",(double)clock()/CLOCKS_PER_SEC); #endif//cout << "Hello world!" << endl;return 0; }

Problem E?最小花費

https://ac.nowcoder.com/acm/contest/906/E

題意:n個城市之間建立 (n - 1)條路把這n個城市連接起來,現已知有建立每條路花費的價值為兩個城市的收益之和,把這n個城市連接起來所花費最小值。

題解:貪心

C++版本一

/* *@Author: STZG *@Language: C++ */ #include <bits/stdc++.h> #include<iostream> #include<algorithm> #include<cstdlib> #include<cstring> #include<cstdio> #include<string> #include<vector> #include<bitset> #include<queue> #include<deque> #include<stack> #include<cmath> #include<list> #include<map> #include<set> //#define DEBUG #define RI register int #define endl "\n" using namespace std; typedef long long ll; //typedef __int128 lll; const int N=100000+10; const int M=100000+10; const int MOD=1e9+7; const double PI = acos(-1.0); const double EXP = 1E-8; const int INF = 0x3f3f3f3f; int t,n,m,k,p,l,r,u,v; int ans,cnt,flag,temp,sum; int a[N]; char str; struct node{}; int main() { #ifdef DEBUGfreopen("input.in", "r", stdin);//freopen("output.out", "w", stdout); #endif//ios::sync_with_stdio(false);//cin.tie(0);//cout.tie(0);//scanf("%d",&t);//while(t--){scanf("%d",&n);for(int i=1;i<=n;i++)scanf("%d",&a[i]),sum+=a[i];sort(a+1,a+n+1);sum+=a[1]*(n-2);cout<<sum<<endl;//}#ifdef DEBUGprintf("Time cost : %lf s\n",(double)clock()/CLOCKS_PER_SEC); #endif//cout << "Hello world!" << endl;return 0; }

Problem F?卑微的Fxx

https://ac.nowcoder.com/acm/contest/906/F

題意:
一個數組,重復k次操作,每次操作都從這個數組中找到最小的不為0的數,輸出這個數,然后把這個數組中所有的數都減去這個數,如果數組中所有的數都為0,則輸出0。

題解:貪心

C++版本一

/* *@Author: STZG *@Language: C++ */ #include <bits/stdc++.h> #include<iostream> #include<algorithm> #include<cstdlib> #include<cstring> #include<cstdio> #include<string> #include<vector> #include<bitset> #include<queue> #include<deque> #include<stack> #include<cmath> #include<list> #include<map> #include<set> //#define DEBUG #define RI register int #define endl "\n" using namespace std; typedef long long ll; //typedef __int128 lll; const int N=100000+10; const int M=100000+10; const int MOD=1e9+7; const double PI = acos(-1.0); const double EXP = 1E-8; const int INF = 0x3f3f3f3f; int t,n,m,k,p,l,r,u,v; int ans,cnt,flag,temp,sum; int a[N]; char str; struct node{}; int main() { #ifdef DEBUGfreopen("input.in", "r", stdin);//freopen("output.out", "w", stdout); #endif//ios::sync_with_stdio(false);//cin.tie(0);//cout.tie(0);//scanf("%d",&t);//while(t--){scanf("%d%d",&n,&k);for(int i=1;i<=n;i++)scanf("%d",&a[i]);sort(a+1,a+n+1);for(int i=1;i<=k;i++){if(a[i]==a[i-1]&&i<=n){k++;continue;}printf("%d%c",i>n?0:a[i]-sum," \n"[i==k]);sum=a[i];}//}#ifdef DEBUGprintf("Time cost : %lf s\n",(double)clock()/CLOCKS_PER_SEC); #endif//cout << "Hello world!" << endl;return 0; }

Problem G?迷惑敵人

https://ac.nowcoder.com/acm/contest/906/G

題意:s個士兵,排成一個r行c列,但有兩個"洞"的矩形方隊,缺失士兵數的所有可能值

題解:數學+思維+枚舉

(其中A為缺失士兵數量,x為厚度,當且僅當為整數時成立)

C++版本一

/* *@Author: STZG *@Language: C++ */ #include <bits/stdc++.h> #include<iostream> #include<algorithm> #include<cstdlib> #include<cstring> #include<cstdio> #include<string> #include<vector> #include<bitset> #include<queue> #include<deque> #include<stack> #include<cmath> #include<list> #include<map> #include<set> //#define DEBUG #define RI register int #define endl "\n" using namespace std; typedef long long ll; //typedef __int128 lll; const int N=100000+10; const int M=100000+10; const int MOD=1e9+7; const double PI = acos(-1.0); const double EXP = 1E-8; const int INF = 0x3f3f3f3f; int t,n,m,k,p,l,r,u,v; int ans,cnt,flag,temp,sum; int main() { #ifdef DEBUGfreopen("input.in", "r", stdin);//freopen("output.out", "w", stdout); #endif//ios::sync_with_stdio(false);//cin.tie(0);//cout.tie(0);//scanf("%d",&t);//while(t--){scanf("%d",&n);for(ll i=1;i<=n/7;i++){ll a=(n-6*i*i)/(7*i);if((n-6.0*i*i)/(7.0*i)==a&&a>0){cout<<"Possible Missing Soldiers = "<<2*(a*a%MOD)%MOD<<endl;cnt++;}}if(cnt==0){cout<<"No Solution Possible"<<endl;return 0;}//}#ifdef DEBUGprintf("Time cost : %lf s\n",(double)clock()/CLOCKS_PER_SEC); #endif//cout << "Hello world!" << endl;return 0; }

Problem H?出題人說這是最簡單的題

https://ac.nowcoder.com/acm/contest/906/H

題意:求s到t的最大流

題解:上下界最大流

C++版本一

/* *@Author: STZG *@Language: C++ */ #include <bits/stdc++.h> #include<iostream> #include<algorithm> #include<cstdlib> #include<cstring> #include<cstdio> #include<string> #include<vector> #include<bitset> #include<queue> #include<deque> #include<stack> #include<cmath> #include<list> #include<map> #include<set> //#define DEBUG #define RI register int #define endl "\n" using namespace std; typedef long long ll; //typedef __int128 lll; const int N=100000+10; const int M=100000+10; const int MOD=1e9+7; const double PI = acos(-1.0); const double EXP = 1E-8; const int INF = 0x3f3f3f3f; const int Maxn=205; const int Maxm=10005; const int inf=1e9; int n,m,size=1,s,t,tot,ans,S,T,sum; int first[Maxn],tmp[Maxn],in[Maxn],out[Maxn],depth[Maxn]; struct shu{int to,next,len,v;}; shu edge[Maxm<<3];inline int get_int() {int x=0,f=1;char c;for(c=getchar();(!isdigit(c))&&(c!='-');c=getchar());if(c=='-') {f=-1;c=getchar();}for(;isdigit(c);c=getchar()) x=(x<<3)+(x<<1)+c-'0';return x*f; }inline void build(int x,int y,int z) {edge[++size].next=first[x];first[x]=size;edge[size].to=y;edge[size].len=z; }inline void pre() {T=n+1;for(int i=1;i<=n;i++){int num=in[i]-out[i];if(num>0) build(S,i,num),build(i,S,0),sum+=num;if(num<0) build(i,T,abs(num)),build(T,i,0);} }inline void delet(){for(int i=tot+1;i<=size;i++) edge[i].len=0;}inline int mn(int x,int y){return x < y ? x : y;}inline bool bfs(int s,int t) {queue<int>q; //建議手寫q.push(s);memset(depth,0,sizeof(depth));depth[s]=1;while(!q.empty()){int point=q.front();q.pop();for(int u=first[point];u;u=edge[u].next){int to=edge[u].to;if(edge[u].len && !depth[to]){depth[to]=depth[point]+1;q.push(to);if(to==t) return 1;}}}return 0; }inline int dinic(int point,int flow,int t) {if(point==t) return flow;int sum=0;for(int &u=tmp[point];u&&sum<flow;u=edge[u].next){int to=edge[u].to;if(edge[u].len && depth[to] == depth[point] + 1){int minn=dinic(to,mn(flow-sum,edge[u].len),t);if(!(flow-sum)) {depth[to]=0;break;}edge[u].len-=minn,edge[u^1].len+=minn,sum+=minn;}}return sum; }int main() { #ifdef DEBUGfreopen("input.in", "r", stdin);//freopen("output.out", "w", stdout); #endif//ios::sync_with_stdio(false);//cin.tie(0);//cout.tie(0);//scanf("%d",&t);//while(t--){//scanf("%d",&n);n=get_int(),m=get_int(),s=get_int(),t=get_int();for(int i=1;i<=m;i++){int x=get_int(),y=get_int(),low=get_int(),up=get_int();in[y]+=low,out[x]+=low,build(x,y,up-low),build(y,x,0);}tot=size;build(t,s,inf),build(s,t,0);pre();while(bfs(S,T)){memcpy(tmp,first,sizeof(first));ans+=dinic(S,inf,T);}if(ans!=sum) {cout<<"please go home to sleep\n";return 0;}first[S]=first[T]=0,ans=0;while(bfs(s,t)){memcpy(tmp,first,sizeof(first));ans+=dinic(s,inf,t);}cout<<ans<<"\n";//}#ifdef DEBUGprintf("Time cost : %lf s\n",(double)clock()/CLOCKS_PER_SEC); #endif//cout << "Hello world!" << endl;return 0; }

?

與50位技術專家面對面20年技術見證,附贈技術全景圖

總結

以上是生活随笔為你收集整理的青岛农业大学第九届ACM程序设计竞赛的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 国产精品久久久久久亚洲伦 | 99re中文字幕 | avtt男人天堂 | 91麻豆产精品久久久久久夏晴子 | www.99热| 99热这里只有精品7 青青草社区 | 99re9| 亚洲一区影视 | 日干夜操| 国产美女网站 | 91精品国产成人 | 国产欧美日韩高清 | 日韩女优在线观看 | 欧美偷拍精品 | 日韩精品久久久久久久 | 国产一区二区在线免费 | 亚洲香蕉av| 欧美日韩高清在线播放 | 精品一区二区久久久久久久网站 | 蜜桃臀一区二区三区 | 中文在线а√在线8 | 欧美大片一区二区三区 | 网站在线看 | 国产视频一区在线播放 | 91精品人妻一区二区三区四区 | 五月婷在线观看 | 日本三级生活片 | 天天摸夜夜添 | 午夜精品极品粉嫩国产尤物 | 我要看免费毛片 | 成年人的黄色片 | 美女调教视频 | 精品一区二区久久久久蜜桃 | www免费网站在线观看 | 色男人影院 | 国产日韩精品中文字无码 | 欧美精品久久96人妻无码 | 精品久久久久久久久久久久久久久久 | 亚洲男人天堂网址 | 国产丝袜精品视频 | 欧美黄色片免费看 | 在线精品亚洲欧美日韩国产 | 精品免费囯产一区二区三区 | 色爽爽爽 | 日本a级网站 | 丰满少妇久久久久久久 | 少妇被按摩师摸高潮了 | 国产精品久久久久久久蜜臀 | 欧美不卡视频 | 亚洲精品九九 | 日韩福利一区二区三区 | 国产精品一线 | 日韩一区二区三区高清 | av片网站 | 看看毛片| 亚洲va韩国va欧美va精品 | 久久综合精品国产二区无码不卡 | 男女男网站| 伊人网大 | 久久久久久久久蜜桃 | 免费a大片 | 国产剧情av麻豆香蕉精品 | 五色天婷婷 | 精品国产乱码久久久 | 手机av资源 | 曰批又黄又爽免费视频 | 亚洲精品乱码久久久久久蜜桃欧美 | 国产精品久久久久久福利 | 成人香蕉网 | 草草影院在线观看 | 国产美女裸体无遮挡免费视频 | 性爱免费在线视频 | www.97ai.com| 成人尤物 | 欧美午夜一区二区 | 欧美日韩69| 欧美黑吊大战白妞 | 亚洲伦理精品 | 少妇高潮一区二区三区在线 | 三年大全国语中文版免费播放 | 亚洲av无码一区二区三区dv | 放荡的少妇2欧美版 | 中文字幕在线观 | 婷婷久草 | 天天操天天曰 | 亚洲精品国产成人av在线 | 99er久久| 国产大片b站 | 欧美日韩国产一级片 | 国产视频精品自拍 | 免费香蕉视频 | 国产精品免费一区二区三区在线观看 | 开元在线观看视频国语 | 日韩精品一区二区亚洲av | 日本午夜精品理论片a级app发布 | 亚洲性在线| 亚洲激情社区 | 自拍亚洲一区 | 日韩欧美区 |