Home >Web Front-end >HTML Tutorial >Codeforces Round #268 (Div. 2)_html/css_WEB-ITnose

Codeforces Round #268 (Div. 2)_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:57:231039browse

Codeforces Round #268 (Div. 2)

Question link

A: Just mark some and judge them

B: Just judge the enumeration times one by one. Can

C: Construct it. 4 and 5 are constructed manually respectively. Then each time there are 2 more numbers, subtract them first to get 1, then multiply by the original number and it remains unchanged. Numbers below 4 cannot be constructed at all.

D: Greedy, sort first, and then each twopointer selects the first and last two to determine which set it can throw into. If it doesn’t work, just find a satisfactory one and throw it into the small set

E: For reasoning, see the official solution for details. After deducing, the interval [x, x 1e18 - 1] is moved one at a time to become [x 1, x 1e18], and the corresponding sum is increased by 1. So as long as it can be calculated [1, 1e18], and then move the corresponding number of steps to get the corresponding interval. Calculate the sum and push rules of 1-1e18 to find out. The official solution also has the formula

Code:

A:

#include <cstdio>#include <cstring>int n, p, q, vis[105];bool solve() {	for (int i = 1; i <= n; i++)		if (vis[i] == 0) return false;	return true;}int main() {	scanf("%d", &n);	scanf("%d", &p);	int tmp;	for (int i = 0; i < p; i++) {		scanf("%d", &tmp);		vis[tmp] = 1;	}	scanf("%d", &q);	for (int i = 0; i < q; i++) {		scanf("%d", &tmp);		vis[tmp] = 1;	}	printf("%s\n", solve() ? "I become the guy." : "Oh, my keyboard!");	return 0;}

B:

#include <cstdio>#include <cstring>const int N = 55;int p, q, l, r, ans;int vis[10005], c[N], d[N];bool judge(int t) {	for (int i = 0; i < q; i++) {		for (int j = c[i]; j <= d[i]; j++) {			if (vis[j + t])				return true;		}	}	return false;}int main() {	scanf("%d%d%d%d", &p, &q, &l, &r);	int a, b;	for (int i = 0; i < p; i++) {		scanf("%d%d", &a, &b);		for (int j = a; j <= b; j++)			vis[j] = 1;	}	for (int i = 0; i < q; i++)		scanf("%d%d", &c[i], &d[i]);	for (int i = l; i <= r; i++) {		if (judge(i)) ans++;	}	printf("%d\n", ans);	return 0;}

C:

#include <cstdio>#include <cstring>#include <vector>#include <algorithm>using namespace std;int n;void solve(int n) {	if (n % 2 == 0) {		printf("1 + 2 = 3\n");		printf("3 + 3 = 6\n");		printf("6 * 4 = 24\n");		for (int i = 5; i <= n; i += 2) {			printf("%d - %d = 1\n", i + 1, i);			printf("24 * 1 = 24\n");		}	} else {		printf("5 - 3 = 2\n");		printf("1 + 2 = 3\n");		printf("2 * 3 = 6\n");		printf("4 * 6 = 24\n");		for (int i = 6; i <= n; i += 2) {			printf("%d - %d = 1\n", i + 1, i);			printf("24 * 1 = 24\n");		}	}}int main() {	scanf("%d", &n);	if (n < 4) printf("NO\n");	else {		printf("YES\n");		solve(n);	}	return 0;}

D:

#include <cstdio>#include <cstring>#include <map>#include <algorithm>using namespace std;const int N = 100005;int n, a, b;map<int, int> to;struct Seq {	int num, id, to, vis;} s[N];bool cmp(Seq a, Seq b) {	return a.num < b.num;}bool cmpid(Seq a, Seq b) {	return a.id < b.id;}int flag = 0;bool solve() {	int st = 0, ed = n - 1;	while (st <= ed) {		if (s[st].vis) {			st++;			continue;		}		if (s[ed].vis) {			ed--;			continue;		}		if (s[st].num + s[ed].num > b || s[st].num + s[ed].num < a)			return false;		if (s[st].num + s[ed].num == b) {			s[st].vis = 1;			s[ed].vis = 1;			s[st].to = 1;			s[ed].to = 1;			st++;			ed--;			continue;		} else if (s[st].num + s[ed].num == a) {			s[st].vis = 0;			s[ed].vis = 0;			s[st].to = 0;			s[ed].to = 0;			st++;			ed--;		} else {			if (!to.count(a - s[st].num)) return false;			int v = to[a - s[st].num];			if (s[v].vis) return false;			s[v].to = 0;			s[v].vis = 1;			s[st].vis = 1;			s[st].to = 0;			st++;		}	}	sort(s, s + n, cmpid);	printf("YES\n");	printf("%d", s[0].to^flag);	for (int i = 1; i < n; i++)		printf(" %d", s[i].to^flag);	printf("\n");	return true;}int main() {	scanf("%d%d%d", &n, &a, &b);	if (a > b) {		swap(a, b);		flag = 1;	}	for (int i = 0; i < n; i++) {		scanf("%d", &s[i].num);		s[i].id = i;	}	sort(s, s + n, cmp);	for (int i = 0; i < n; i++)		to[s[i].num] = i;	if (!solve()) printf("NO\n");	return 0;}

E:

#include <cstdio>#include <cstring>#include <algorithm>using namespace std;typedef long long ll;const ll INF = 1e18;ll a;int main() {	scanf("%lld", &a);	ll num = INF / 10 % a;	num = num * 2 % a;	num = num * 9 % a;	num = num * 9 % a;	num = num * 5 % a;	printf("%lld %lld\n", a - num, a - num + INF - 1);	return 0;}


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn