当前位置:网站首页>Codeforces Round #620 (Div. 2)ABC
Codeforces Round #620 (Div. 2)ABC
2022-06-23 17:17:00 【leimingzeOuO】
A. Two Rabbits
The distance between two points decreases each time a+b, The initial distance is y-x
If two people happen to meet , that (y-x)%(a+b)==0
Time is (y-x)/(a+b)
#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
#define x first
#define y second
#define LL long long
#define int LL
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define PII pair<int,int>
#define ll_INF 0x7f7f7f7f7f7f7f7f
#define INF 0x3f3f3f3f
#define debug(x) cerr << #x << ": " << x << endl
#define io ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
LL Mod(LL a,LL mod){
return (a%mod+mod)%mod;}
LL lowbit(LL x){
return x&-x;}// Its lowest 1 And behind it 0 The value of composition
LL qmi(LL a,LL b,LL mod) {
LL ans = 1; while(b){
if(b & 1) ans = ans * (a % mod) % mod; a = a % mod * (a % mod) % mod; b >>= 1;} return ans; }
int _;
int n;
int gcd(int a,int b)
{
return b?gcd(b,a%b):a;
}
void solve()
{
int x,y,a,b;
cin>>x>>y>>a>>b;
if((y-x)%(a+b))cout<<-1<<endl;
else cout<<(y-x)/(a+b)<<endl;
}
signed main()
{
io;
cin>>_;
while(_--)
solve();
return 0;
}
B. Longest Palindrome
Ideas : Violence enumeration , First, find out your palindrome and put it in the middle , There can only be one
Then store the characters of mutual palindromes and output them
#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
#define x first
#define y second
#define LL long long
#define int LL
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define PII pair<int,int>
#define ll_INF 0x7f7f7f7f7f7f7f7f
#define INF 0x3f3f3f3f
#define debug(x) cerr << #x << ": " << x << endl
#define io ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
LL Mod(LL a,LL mod){
return (a%mod+mod)%mod;}
LL lowbit(LL x){
return x&-x;}// Its lowest 1 And behind it 0 The value of composition
LL qmi(LL a,LL b,LL mod) {
LL ans = 1; while(b){
if(b & 1) ans = ans * (a % mod) % mod; a = a % mod * (a % mod) % mod; b >>= 1;} return ans; }
int _;
int n,m;
const int N=110;
vector<string>v;
int gcd(int a,int b)
{
return b?gcd(b,a%b):a;
}
bool check(string s)
{
string t=s;
reverse(all(t));
return s==t;
}
void solve()
{
cin>>n>>m;
string s;
map<string,bool>mp;
vector<string>v1,v2;
string mid="";
for(int i=0;i<n;i++)
{
cin>>s;
v.pb(s);
}
for(int i=0;i<n;i++)
{
if(check(v[i]))
{
mid=v[i];
continue;
}
for(int j=0;j<n;j++)
{
if(j==i)continue;
string t=v[i]+v[j];
if(check(t)&&mp[v[i]]==false&&mp[v[j]]==false)
{
v1.pb(v[i]);
v2.pb(v[j]);
mp[v[i]]=mp[v[j]]=true;
}
}
}
int len=v1.size()+v2.size();
if(mid!="")len++;
cout<<len*m<<endl;
for(int i=0;i<v1.size();i++)cout<<v1[i];
if(mid!="")cout<<mid;
for(int i=v2.size()-1;i>=0;i--)cout<<v2[i];
cout<<endl;
}
signed main()
{
io;
// cin>>_;
// while(_--)
solve();
return 0;
}
C. Air Conditioner
Ideas : greedy , Maintenance interval
#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
#define x first
#define y second
#define LL long long
#define int LL
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define PII pair<int,int>
#define ll_INF 0x7f7f7f7f7f7f7f7f
#define INF 0x3f3f3f3f
#define debug(x) cerr << #x << ": " << x << endl
#define io ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
LL Mod(LL a,LL mod){
return (a%mod+mod)%mod;}
LL lowbit(LL x){
return x&-x;}// Its lowest 1 And behind it 0 The value of composition
LL qmi(LL a,LL b,LL mod) {
LL ans = 1; while(b){
if(b & 1) ans = ans * (a % mod) % mod; a = a % mod * (a % mod) % mod; b >>= 1;} return ans; }
int _;
int n,m;
const int N=110;
struct node
{
int t,l,r;
}c[N];
void solve()
{
cin>>n>>m;
for(int i=1;i<=n;i++)cin>>c[i].t>>c[i].l>>c[i].r;
bool f=false;
int l=m,r=m;
for(int i=1;i<=n;i++)
{
int d=c[i].t-c[i-1].t;
l-=d,r+=d;
if(l>c[i].r||r<c[i].l)
{
f=true;
break;
}
l=max(l,c[i].l),r=min(r,c[i].r);
}
if(f)cout<<"NO"<<endl;
else cout<<"YES"<<endl;
}
signed main()
{
io;
cin>>_;
while(_--)
solve();
return 0;
}
边栏推荐
- Importance and purpose of test
- Identify and stop the process that's listening on port 8080 or configure this application
- 你女朋友也能读懂的LAMP架构
- R language plot visualization: plot visualization adds bar chart with error bars with plot in R
- Is it cost-effective to buy a long-term financial product?
- 移动云共筑信创云能力底座,助力中国信创产业发展
- QT布局管理器【QVBoxLayout,QHBoxLayout,QGridLayout】
- [go] calling Alipay to scan code for payment in a sandbox environment
- Opengauss database source code analysis series articles -- detailed explanation of dense equivalent query technology (Part 1)
- C # connection to database
猜你喜欢

The official Chinese course of zero foundation introduction jetpack compose is coming

使用Jmeter进行性能测试及性能监控平台搭建

《MPLS和VP体系结构》

【30. 串联所有单词的子串】
![[untitled] Application of laser welding in medical treatment](/img/c5/9c9edf1c931dfdd995570fa20cf7fd.png)
[untitled] Application of laser welding in medical treatment

数学分析_证明_第1章:可数个可数集之并为可数集

JS common error reporting and exception capture

DataNode进入Stale状态问题排查

亚朵更新招股书:继续推进纳斯达克上市,已提前“套现”2060万元

Easyplayer mobile terminal plays webrtc protocol for a long time. Pressing the play page cannot close the "about us" page
随机推荐
I successfully joined the company with 27K ByteDance. This interview notes on software testing has benefited me for life
JS常见的报错及异常捕获
创新技术领航者!华为云GaussDB获颁2022年云原生数据库领域权威奖项
数学分析_证明_第1章:可数个可数集之并为可数集
How to make sales management more efficient?
亚朵更新招股书:继续推进纳斯达克上市,已提前“套现”2060万元
Network remote access raspberry pie (VNC viewer)
Lamp architecture that your girlfriend can read
The connection between supply and demand will no longer depend on the platform and center of the Internet Era
[qsetting and.Ini configuration files] and [create resources.qrc] in QT
C. Product 1 Modulo N-Codeforces Round #716 (Div. 2)
R language uses colorblinr package to simulate color blind vision, and uses edit to visualize the image of ggplot2_ The colors function is used to edit and convert color blindness into visual results
ABAP essays - program optimization notes
Safe and comfortable, a new generation of Qijun carefully interprets the love of the old father
ABAP随笔-物料主数据界面增强
Stick to five things to get you out of your confusion
数字经济加速落地,能为中小企业带来什么?
Robot Orientation and some misunderstandings in major selection in college entrance examination
The company recruited a tester with five years' experience and saw the real test ceiling
How do you choose to buy stocks? Good security?