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

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;
}

抱歉,根据提供的引用内容,我无法理解你具体想要问什么问题。请提供更清晰明确的问题,我将竭诚为你解答。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [Codeforces Round 860 (Div. 2)题解](https://blog.csdn.net/qq_60653991/article/details/129802687)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *2* [【CodeforcesCodeforces Round 865 (Div. 2) (补赛)](https://blog.csdn.net/t_mod/article/details/130104033)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *3* [Codeforces Round 872 (Div. 2)(前三道](https://blog.csdn.net/qq_68286180/article/details/130570952)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 33.333333333333336%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值