Codeforces Round 880 (Div. 2)(VP-13,寒假加训)

发布时间:2024年01月14日

VP时间

A.

计数器

比较c[i]与c[i+1]

1.ac

B.

数学?

好贪

让(n-1)个人都拿g/2(向上取整)-1,这样每个人都拿不到

或者全部人都拿g/2(向上取整)-1,省的是g/2-1,综合一下还是ans

最后一个人拿完全部

1.wa2

2.wa2

3,.wa2

4.g得奇数偶数

或者直接变成(a+b-1/b)(向下取整)

1.g&1

g/2(向上取整)==g/2

2.!(g&1)

g/2(向上取整==g/2-1

4.ac

C.

没时间

题解

A.

// Problem: A. Destroyer
// Contest: Codeforces - Codeforces Round 880 (Div. 2)
// URL: https://codeforces.com/contest/1836/problem/A
// Memory Limit: 256 MB
// Time Limit: 1000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

#include<bits/stdc++.h>
#define eps 1e-5
#define INF 1e9
using namespace std;
typedef long long ll;
const int N = 2e6 + 9;
int a[N],c[N];
void Lan(){
	int n;
	cin>>n;
	memset(c,0,sizeof(c));
	for(int i=1;i<=n;i++){
		cin>>a[i];
		c[a[i]]++;
	}
	bool ok=true;
	for(int i=0;i<=100;i++){
		if(c[i+1]>c[i]){
			ok=false;
		}
	}
	if(!ok){
		cout<<"NO"<<'\n';
	}else{
		cout<<"YES"<<'\n';
	}
	
		
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	int q;
	cin>>q;
	while (q--) {
		Lan();
	}
	return 0;
}

B.

1.

// Problem: B. Astrophysicists
// Contest: Codeforces - Codeforces Round 880 (Div. 2)
// URL: https://codeforces.com/contest/1836/problem/B
// Memory Limit: 256 MB
// Time Limit: 1000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

#include<bits/stdc++.h>
#define eps 1e-5
#define INF 1e9
using namespace std;
typedef long long ll;
void Lan(){
	ll n,k,g;
	cin>>n>>k>>g;
	ll sum=min(k*g,(g-1)/2*n);
	ll res=(k*g-sum)%g;
	if(res>0){
		sum-=(g-1)/2;
		ll ans=((g-1)/2+res)%g;
		if(ans*2<g){
			sum+=ans;
		}else{
			sum-=g-ans;
		}
	}
	cout<<sum<<'\n';
	
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	int q;
	cin>>q;
	while (q--) {
		Lan();
	}
	return 0;
}

2.

// Problem: B. Astrophysicists
// Contest: Codeforces - Codeforces Round 880 (Div. 2)
// URL: https://codeforces.com/contest/1836/problem/B
// Memory Limit: 256 MB
// Time Limit: 1000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

#include<bits/stdc++.h>
#define eps 1e-5
#define INF 1e9
using namespace std;
typedef long long ll;
void Lan(){
	ll n,k,g;
	cin>>n>>k>>g;
	ll ans=0;
	if(g&1){
		ans=(g/2)*n;
	}else{
		ans=(g/2-1)*n;
	}
	ans/=g;
	if(ans>k){
		ans=k;
	}
	cout<<ans*g<<'\n';
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	int q;
	cin>>q;
	while (q--) {
		Lan();
	}
	return 0;
}

C.

题意原来是找按字典树找第k个满足等式的

枚举a就好了

// Problem: C. k-th equality
// Contest: Codeforces - Codeforces Round 880 (Div. 2)
// URL: https://codeforces.com/contest/1836/problem/C
// Memory Limit: 256 MB
// Time Limit: 1000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

#include<bits/stdc++.h>
#define eps 1e-5
#define INF 1e9
using namespace std;
typedef long long ll;
const int N = 2e6 + 9;
int t[10]={1,10,100,1000,10000,100000,1000000};
void Lan(){
	int a,b,c;
	ll k;
	cin>>a>>b>>c>>k;
	bool ok=false;
		for(int i=t[a-1];i<t[a];i++){
			int l=t[b-1],r=t[b]-1;
			 l=max(l,t[c-1]-i);
			 r=min(r,t[c]-1-i);
			if(r<l){
				continue;
			}
			if(k>r-l+1){
				k-=r-l+1;
				continue;
			}
			cout<<i<<" "<<"+"<<" "<<l+k-1<<" "<<"="<<" "<<i+(l+k-1)<<'\n';
			ok=true;
			break;
		}
	if(!ok){
		cout<<-1<<'\n';
	}
}
	
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	int q;
	cin>>q;
	while (q--) {
		Lan();
	}
	return 0;
}

文章来源:https://blog.csdn.net/Lanthamum/article/details/135586163
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。