Codeforces Round #755 (Div. 2, based on Technocup 2022 Elimination Round 2) ABC
2021/11/16 23:39:56
本文主要是介绍Codeforces Round #755 (Div. 2, based on Technocup 2022 Elimination Round 2) ABC,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
Problem - A - Codeforces
题目大意:给定u,v,求x,y。要满足x/u + y/v =( x+y) / (u+v)
input
4 1 1 2 3 3 5 6 9output
-1 1 -4 9 -18 50 -4 9
u*u *y=-x *v*v so y=-x*v*v/u*u 开longlong即可
#include<iostream> #include<cmath> #include<algorithm> using namespace std; int main() { cin.tie(0); cout.tie(0); ios::sync_with_stdio(false); int t; cin>>t; while(t--) { long long int u,v; cin>>u>>v; if(u==v) cout<<"-1 1"<<endl; else { long long int x=u*u; long long int y=-v*v; cout<<x<<" "<<y<<endl; } } return 0; }
Problem - B - Codeforces
题目大意:n*m的红色矩形,除1*1外可任意裁剪。为了让相邻的任意一对单元格(来自同一片断)具有不同的颜色。
问至少要画多少个单元格?
input
4 1 3 2 2 2 5 3 5output
1 2 4 5
切入点就是3格划分为最小,划完3格的,余下2格的再划一格
#include<iostream> #include<cmath> #include<algorithm> using namespace std; int main() { cin.tie(0); cout.tie(0); ios::sync_with_stdio(false); int t; cin>>t; while(t--) { int a,b; cin>>a>>b; int flag; if(a>b) { flag=a; a=b; b=flag; } if(a%3==0) cout<<b*(a/3)<<endl; else if(b%3==0) cout<<a*(b/3)<<endl; else cout<<a/3*b+(a%3==1?b/3+(b%3>0?1:0):b/3*2+b%3)<<endl; } return 0; }
Problem - C - Codeforces
题目大意:a数组能否经历+1或不动变为b数组。可以为“YES”,反之“NO”。
input
3 3 -1 1 0 0 0 2 1 0 2 5 1 2 3 4 5 1 2 3 4 5output
YES NO YES
#include<iostream> #include<cmath> #include<algorithm> using namespace std; int main() { cin.tie(0); cout.tie(0); ios::sync_with_stdio(false); int t; cin>>t; while(t--) { int n; cin>>n; int a[200200],b[200200]; for(int i=1;i<=n;i++) cin>>a[i]; for(int i=1;i<=n;i++) cin>>b[i]; sort(a+1,a+1+n); sort(b+1,b+1+n); bool flag=true; for(int i=1;i<=n;i++) if(b[i]-a[i]==1||b[i]==a[i]) continue; else { flag=false; break; } if(flag==false) cout<<"NO"<<endl; else cout<<"YES"<<endl; } return 0; }
嘎嘎冲!
这篇关于Codeforces Round #755 (Div. 2, based on Technocup 2022 Elimination Round 2) ABC的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-07-05feign默认connecttimeout和readtimeout是多少-icode9专业技术文章分享
- 2024-07-05idea控制台,日志太多,导致部分想看得日志被刷走 搜不到-icode9专业技术文章分享
- 2024-07-05The server selected protocol version Tls10 is not accepted by client preferences [TLs12]-icode9专业技术文章分享
- 2024-07-05怎么清理项目缓存-icode9专业技术文章分享
- 2024-07-04安装 Eyoucms详细图文教程-icode9专业技术文章分享
- 2024-07-04ueditor 复制文章时,图片的链接是一个下载图片地址,该如何处理?-icode9专业技术文章分享
- 2024-07-04怎样判断host有没有对wordpress有缓存呢-icode9专业技术文章分享
- 2024-07-04具有编译功能的系统make后,无法ssh连接-icode9专业技术文章分享
- 2024-07-04make后如何升级ssh-icode9专业技术文章分享
- 2024-07-03微信支付提示下单账户与支付账户不一致-icode9专业技术文章分享