Educational Codeforces Round 112 (Rated for Div. 2)
2021/7/31 6:08:15
本文主要是介绍Educational Codeforces Round 112 (Rated for Div. 2),对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
A. PizzaForces
打表就会神奇的发现规律(当时想错了错好几发)
#include "bits/stdc++.h" #define pll __builtin_popcount #define all(a) a.begin(),a.end() #define pb push_back using namespace std; using ll = long long ; inline void solve() { ll n;cin>>n; if(n<=6){ cout<<15<<"\n"; }else{ if(n%2==0)n--; n-=4; n=n/2+1; cout<<n*5+10<<"\n"; } } int main() { //freopen("out.txt","w",stdout); //int a[]={15,15,15,15,15,15,20,20,25,25,30,30,35,35,40,40,45,45,50,50,55,55,60,60,65,65,70,70,75,75,80,80,85,85,90,90,95,95,100,100,105,105,110,110,115,115,120,120,125,125,130,130,135,135,140,140,145,145,150,150,155,155,160,160,165,165,170,170,175,175,180,180,185,185,190,190,195,195,200,200,205,205,210,210,215,215,220,220,225,225,230,230,235,235,240,240,245,245,250,250,255,255,260,260,265,265,270,270,275,275,280,280,285,285,290,290,295,295,300,300,305,305,310,310,315,315,320,320,325,325}; //for(int i=1;i<=130;i++)mp[i]=a[i-1]; ios::sync_with_stdio(false); int T=1; cin>>T; while(T--) solve(); return 0; }
B. Two Tables
尽可能把能移动的对称到右上角不能移动的放左下角
#include "bits/stdc++.h" #define pll __builtin_popcount #define all(a) a.begin(),a.end() #define pb push_back using namespace std; using ll = long long ; void solve() { int w,h; cin>>w>>h; int a,b,c,d; cin>>a>>b>>c>>d; if(a<w-c){ int p=w-c-a; a+=p; c+=p; } if(b<h-d){ int p=h-d-b; b+=p; d+=p; } int u,v; cin>>u>>v; if(a<u&&b<v){ int ans=0x3f3f3f3f; int p=u-a; if(c+p<=w)ans=p; p=v-b; if(d+p<=h)ans=min(ans,p); if(ans==0x3f3f3f3f){ cout<<"-1\n";return ; } cout<<(double)ans<<"\n"; return ; } cout<<(double)0<<"\n"; } int main() { cout<<fixed<<setprecision(9); ios::sync_with_stdio(false); int T=1; cin>>T; while(T--) solve(); return 0; }
C. Coin Rows
题意Alice和Bob想走到2,m且Alice走过的路的权值都会变成0,Alice想让Bob走的权值的和最小,Bob与之相反问答案在二者最优的情况是多少(前缀和模拟下就行了)
#include "bits/stdc++.h" #define pll __builtin_popcount #define all(a) a.begin(),a.end() #define pb push_back using namespace std; using ll = long long ; ll a[3][100002]; void solve() { int n; cin>>n; for(int i=1;i<=2;i++) for(int j=1;j<=n;j++)cin>>a[i][j]; for(int i=1;i<=2;i++) for(int j=1;j<=n;j++) a[i][j]+=a[i][j-1]; ll ans=1e18; for(int i=1;i<=n;i++){ ans=min(ans,max(a[1][n]-a[1][i],a[2][i-1]-a[2][0])); } cout<<ans<<"\n"; } int main() { //cout<<fixed<<setprecision(9); ios::sync_with_stdio(false); int T=1; cin>>T; while(T--) solve(); return 0; }
这篇关于Educational Codeforces Round 112 (Rated for Div. 2)的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2025-01-01使用 SVN合并操作时,怎么解决冲突的情况?-icode9专业技术文章分享
- 2025-01-01告别Anaconda?试试这些替代品吧
- 2024-12-31自学记录鸿蒙API 13:实现人脸比对Core Vision Face Comparator
- 2024-12-31自学记录鸿蒙 API 13:骨骼点检测应用Core Vision Skeleton Detection
- 2024-12-31自学记录鸿蒙 API 13:实现人脸检测 Core Vision Face Detector
- 2024-12-31在C++中的双端队列是什么意思,跟消息队列有关系吗?-icode9专业技术文章分享
- 2024-12-31内存泄漏(Memory Leak)是什么,有哪些原因和优化办法?-icode9专业技术文章分享
- 2024-12-31计算机中的内存分配方式堆和栈有什么关系和特点?-icode9专业技术文章分享
- 2024-12-31QT布局器的具体使用原理和作用是什么?-icode9专业技术文章分享
- 2024-12-30用PydanticAI和Gemini 2.0构建Airflow的AI助手