Atcoder beginner contest 112(水题大赛)

第一次打atcoder,当时并不清楚beginner是个啥水平,以为和cf的div2一个水准,打开一看……我TM这是什么鬼

AB甚至不如2001普及组……

AB过水,跳过

C

题意:一个金字塔上的每一个点有一个坐标和一个高度,金字塔有一个中心坐标和塔高,给出每个点的高度计算公式

给你n个点的信息(高度,坐标),求高度、Cx和Cy,n , Cx, Cy <= 100

就是类似于CF978D Almost Arithmetic Progression的一个思路,枚举Cx, Cy选取一个高度非零的点,计算出H,枚举每个点判断行不行,n^3可过

#include 
#define LL long long
#define db double
using namespace std;
 
const int MAXN = 2002;
const int MAXE = 400400;
const int INF = 0x3f3f3f3f;
 
template inline void CheckMax(T &A, T B) {
	A < B ? A = B : A;
}
 
template inline void CheckMin(T &A, T B) {
	A > B ? A = B : A;
}
 
template  inline void read(T &x) {
    int c = getchar();
    bool f = false;
    for (x = 0; !isdigit(c); c = getchar()) {
        if (c == '-') {
            f = true;
        }
    }
    for (; isdigit(c); c = getchar()) {
        x = x * 10 + c - '0';
    }
    if (f) {
        x = -x;
    }
}
 
int n;
typedef pair pii;
typedef pair ppi;
#define X first
#define Y second
 
ppi p[MAXN];
 
bool check(int x, int y) {
	int pos = 1;
	while(p[pos].Y == 0) pos++;
	int tmp = abs(x - p[pos].X.X), tmp2 = abs(y - p[pos].X.Y);
	int h = p[pos].Y + tmp + tmp2;
	for(int i = 1; i <= n; i++) {
		if(i == pos) continue;
		tmp = abs(x - p[i].X.X), tmp2 = abs(y - p[i].X.Y);
		if(h - tmp - tmp2 < 0) {
			if(p[i].Y == 0) continue;
			else return 0;
		}
		if(p[i].Y + tmp + tmp2 != h) return 0;
	}
	return 1;
}
 
signed main() {
	read(n);
	srand((unsigned int) time(NULL));
	for(int i = 1; i <= n; i++) {
		read(p[i].X.X), read(p[i].X.Y);
		read(p[i].Y);
	}
	random_shuffle(p + 1, p + n + 1);
	for(int i = 0; i <= 100; i++) {
		for(int j = 0; j <= 100; j++) {
			if(check(i, j)) {
				int pos = 1;
				while(p[pos].Y == 0) pos++;
				int tmp = abs(i - p[pos].X.X), tmp2 = abs(j - p[pos].X.Y);
				int h = p[pos].Y + tmp + tmp2;
				printf("%d %d %d\n", i, j, h);
				return 0;
			}
		}
	}
	return 0;
}

D

一个长度为N的数列的总和为M,求该数列所有数的可能的最大gcd

CF900D的极限弱化版

#include 
#define LL long long
#define db double
using namespace std;
 
const int MAXN = 200200;
const int MAXE = 400400;
const int INF = 0x3f3f3f3f;
 
template inline void CheckMax(T &A, T B) {
	A < B ? A = B : A;
}
 
template inline void CheckMin(T &A, T B) {
	A > B ? A = B : A;
}
 
template  inline void read(T &x) {
    int c = getchar();
    bool f = false;
    for (x = 0; !isdigit(c); c = getchar()) {
        if (c == '-') {
            f = true;
        }
    }
    for (; isdigit(c); c = getchar()) {
        x = x * 10 + c - '0';
    }
    if (f) {
        x = -x;
    }
}
 
int n, m;
int P[MAXN], cnt;
 
int solve() {
	int ans = 0;
	for(int i = 1; i * i <= m; i++) {
		if(m % i == 0) {
			if(m / i >= n) CheckMax(ans, i);
			if(m / (m / i) >= n) CheckMax(ans, m / i);
		}
	}
	return ans;
}
 
signed main() {
	read(n), read(m);
	printf("%d\n", solve());
	return 0;
}

 

你可能感兴趣的:(Atcoder,简单题)