csust-8.14早训CF之1000-2000分

目录

 

A - Treasure Hunt

B - Makes And The Product

C - Really Big Numbers

D - Diplomas and Certificates

E - Permutation Game

F - Sofa Thief


A - Treasure Hunt

 CodeForces - 817A 

题目链接https://codeforces.com/problemset/problem/817/A

#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false)
#define ok(x) (x>0 && x<150000)
const int mac = 2e5 + 10;
int a[mac], vis[mac];
int main()
{
	IOS;
	int x1, x2, y11, y2, x, y;
	cin >> x1 >> y11 >> x2 >> y2;
	cin >> x >> y;
	if (abs(y2 - y11) % y) {
		cout << "NO" << endl;
	}
	else {
		int p = abs(y2 - y11) / y;
		int pp = abs(x2 - x1) / x;
		if (abs(x2-x1)%x) cout<<"NO\n";
		else if (abs(p - pp) & 1) cout << "NO\n";
		else if ((abs(p-pp)&1)==0) cout << "YES\n";
	} 
	return 0;
}

B - Makes And The Product

 CodeForces - 817B 

题目链接https://codeforces.com/problemset/problem/817/B

#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false)
#define ok(x) (x>0 && x<150000)
#define ll long long
const int mac = 2e5 + 10;
const int inf = 1e8 + 10;
int a[mac], vis[mac];
int main()
{
	IOS;
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	sort(a + 1, a + 1 + n);
	int x1 = inf, x2 = inf, x3 = inf;
	x1 = a[1]; x2 = a[2]; x3 = a[3];
	ll nb1=0, nb2=0, nb3=0;
	for (int i = 1; i <= n; i++) {
		if (a[i] == x1) nb1++;
		else if (a[i] == x2) nb2++;
		else if (a[i] == x3) nb3++;
	}
	//ll p1 = nb1, p2 = nb2 - nb1, p3 = nb3 - nb2;
	if (x1 != x2 && x2 != x3 && x1 != x3) {
		cout << nb1 * nb2 * nb3 << endl;
	}
	else if (x1 == x2 && x1 != x3) {
		cout << nb3 << endl;
	}
	else if (x2 == x3 && x1 != x2) cout << nb2 * (nb2 - 1) / 2 << endl;
	else if (x1 == x2 && x2 == x3) {
		 cout << nb1 * (nb1 - 1) * (nb1 - 2) / 6 << endl;
	}
	return 0;
}

C - Really Big Numbers

 CodeForces - 817C 

题目链接https://codeforces.com/problemset/problem/817/C

#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false)
#define ll long long
const int mac = 2e5 + 10;
const int inf = 1e8 + 10;
int a[mac], vis[mac], b[mac];
ll s, n;
int ok(ll x);
int main()
{
	IOS;
	cin >> n >> s;
	ll l = 10, r = n, mid, ans=-1;
	while (l <= r) {
		mid = (l + r) >> 1;
		if (ok(mid)) {
			r = mid - 1;
			ans = mid;
		}
		else l = mid + 1;
	}
	if (ans == -1) cout << 0 << endl;
	else cout << n - ans + 1;
	return 0;
}
int ok(ll x)
{
	ll p = x, sum = 0;
	while (p) {
		sum += p % 10;
		p /= 10;
	}
	if (x - sum >= s) return 1;
	return 0;
}

D - Diplomas and Certificates

 CodeForces - 818A 

题目链接https://codeforces.com/problemset/problem/818/A

#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false)
#define ok(x) (x>0 && x<150000)
#define ll long long
const int mac = 2e5 + 10;
const int inf = 1e8 + 10;
int a[mac], vis[mac];
int main()
{
	IOS;
	ll n, k;
	cin >> n >> k;
	ll p = n / 2;
	ll u = p / (k + 1);
	if (u==0) cout<<"0 0 "<<n<<endl;
	else cout << u << " " << k*u << " " << n - u-k*u<< endl;
	return 0;
}

E - Permutation Game

 CodeForces - 818B 

题目链接https://codeforces.com/problemset/problem/818/B

#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false)
#define ok(x) (x>0 && x<150000)
#define ll long long
const int mac = 2e5 + 10;
const int inf = 1e8 + 10;
int a[mac], vis[mac], b[mac],v[mac];
int main()
{
	IOS;
	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= m; i++)
		cin >> a[i];
	int mod = n;
	for (int i = 1; i <= m - 1; i++) {
		if (vis[b[a[i]]]) {
			int p = (a[i + 1] - a[i] + mod) % mod;
			if (!p) p = n;
			if (p != b[a[i]]) { cout << -1 << endl; return 0; }
		}
		else b[a[i]] = (a[i + 1] - a[i] + mod) % mod;
		if (b[a[i]] == 0) b[a[i]] = n;
		vis[b[a[i]]] = 1;
	}
	for (int i = 1; i <= n; i++) {
		if (!b[i]) {
			for (int j=1; j<=n; j++) 
				if (!vis[j]) { b[i] = j; vis[j] = 1; break; }
		}
	}
	for(int i=1; i<=n; i++){
		if (!v[b[i]]) v[b[i]]=1;
		else {
			cout<<-1<<endl;return 0;
		}
	} 	
	for (int i = 1; i < n; i++) cout << b[i] << " ";
	cout << b[n] << endl;
	return 0;
}

F - Sofa Thief

 CodeForces - 818C 

题目链接https://codeforces.com/problemset/problem/818/C

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值