Codeforces Round #834 (Div. 3)(补)

A. 模拟

#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define pb push_back
#define ll long long
const int INF=0x3f3f3f3f;
const int N=1e6+10,M=1e6+10;

void solve(){
	string s;cin>>s;
	if(s[0]=='Y'){
		for(int i=1;i<s.size();i++){
			if(i%3==1){
				if(s[i]!='e'){
					cout<<"NO"<<'\n';return ;
				}
			}
			if(i%3==2){
				if(s[i]!='s'){
					cout<<"NO"<<'\n';return ;
				}
			}
			if(i%3==0){
				if(s[i]!='Y'){
					cout<<"NO"<<'\n';return ;
				}
			}
		}
	}
	else if(s[0]=='e'){
		for(int i=1;i<s.size();i++){
			if(i%3==1){
				if(s[i]!='s'){
					cout<<"NO"<<'\n';return ;
				}
			}
			if(i%3==2){
				if(s[i]!='Y'){
					cout<<"NO"<<'\n';return ;
				}
			}
			if(i%3==0){
				if(s[i]!='e'){
					cout<<"NO"<<'\n';return ;
				}
			}
		}
	}
	else if(s[0]=='s'){
		for(int i=1;i<s.size();i++){
			if(i%3==1){
				if(s[i]!='Y'){
					cout<<"NO"<<'\n';return ;
				}
			}
			if(i%3==2){
				if(s[i]!='e'){
					cout<<"NO"<<'\n';return ;
				}
			}
			if(i%3==0){
				if(s[i]!='s'){
					cout<<"NO"<<'\n';return ;
				}
			}
		}
	}
	for(auto c: s){
		if(c!='e'&&c!='s'&&c!='Y'){
			cout<<"NO"<<'\n';return ;
		}
	}
	 cout<<"YES"<<'\n'; 
}

signed main(){
	ios::sync_with_stdio(false);
    cin.tie(0);
	int t;cin>>t;
	//int t=1;
	while(t--){
		solve();
	}
} 

B. 模拟

#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define pb push_back
#define ll long long
const int INF=0x3f3f3f3f;
const int N=1e6+10,M=1e6+10;

void solve(){
	int m,s;cin>>m>>s;int maxx=0,a[2000],mp[2000]={0};
	for(int i=1;i<=m;i++){
		int x;cin>>x;mp[x]=1;
		maxx=max(maxx,x);
	}
	for(int i=1;i<=maxx;i++){
		if(!mp[i])s-=i;
	}
	if(s==0){
		cout<<"YES"<<'\n';return ;
	}
	while(s>0){
		maxx++;
		s-=maxx;
		if(s==0){
			cout<<"YES"<<'\n';return ;
		}
	}
	cout<<"NO"<<'\n';
}

signed main(){
	ios::sync_with_stdio(false);
    cin.tie(0);
	int t;cin>>t;
	//int t=1;
	while(t--){
		solve();
	}
} 

C. if 

#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define pb push_back
#define ll long long
const int INF=0x3f3f3f3f;
const int N=1e6+10,M=1e6+10;

void solve(){
	ll l,r,x,a,b;cin>>l>>r>>x>>a>>b;
	if(a==b){
		cout<<0<<'\n';return ;
	}
	if(abs(a-b)>=x){
		cout<<1<<'\n';return ;
	}
	if(a-l<x&&r-a<x){
		cout<<-1<<'\n';return ;
	}
	if(a-l>=x&&b-l>=x){
		cout<<2<<'\n';return ;
	}
	if(r-a>=x&&r-b>=x){
		cout<<2<<'\n';return ;
	}
	if(a-l>=x&&r-b>=x){
		cout<<3<<'\n';return ;
	}
	if(r-a>=x&&b-l>=x){
		cout<<3<<'\n';return ;
	}
	cout<<-1<<'\n';
}

signed main(){
	ios::sync_with_stdio(false);
    cin.tie(0);
	int t;cin>>t;
	//int t=1;
	while(t--){
		solve();
	}
} 

D. n 的末尾0一定会加到最后的结果里 我们因为是乘法 我们只需要找2和5 即可

#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define pb push_back
#define ll long long
const int INF=0x3f3f3f3f;
const int N=1e6+10,M=1e6+10;

void solve(){
	ll n,m;cin>>n>>m;ll k=n;
	ll cnt2=0,cnt5=0,cnt=0;ll sum=n;
	while(n%10==0)n/=10;
	sum=n;
	while(sum%2==0)sum/=2,cnt2++;
	sum=n;
	while(sum%5==0)sum/=5,cnt5++;
	while(m>=2&&cnt5>0)m/=2,cnt5--,k*=2;
	while(m>=5&&cnt2>0)m/=5,cnt2--,k*=5;
	while(m>=10)m/=10,k*=10;
	cout<<k*m*1ll<<'\n';
}

signed main(){
	ios::sync_with_stdio(false);
    cin.tie(0);
	int t;cin>>t;
	//int t=1;
	while(t--){
		solve();
	}
}

E. 暴力 

#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define pb push_back
#define ll long long
const int INF=0x3f3f3f3f;
const int N=1e6+10,M=1e6+10;

void solve(){
	ll n,h;cin>>n>>h;ll a[200010],maxx=0;
	for(int i=1;i<=n;i++)cin>>a[i];
	sort(a+1,a+1+n);
	for(int k=1;k<=3;k++){
		ll ans=0,now=h,cnt=0;
		for(int i=1;i<=n;i++){
			if(a[i]<now)now+=a[i]/2,ans++;
			else {
				if(cnt<3){
					cnt++;i--;
					if(cnt==k)now*=3;
					else now*=2;
				}
			}
		}
		maxx=max(maxx,ans);
	}
	cout<<maxx<<'\n';
}

signed main(){
	ios::sync_with_stdio(false);
    cin.tie(0);
	int t;cin>>t;
	//int t=1;
	while(t--){
		solve();
	}
} 

F 好像是一个珂朵莉树的区间思想

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值