2020 Multi-University Training Contest 4

6803 Blow up the Enemy

难得一见的比赛水题

#include
#include
#include
using namespace std;
const int maxn = 1000 + 5;
int T, n, A[maxn], D[maxn];
int main(void) {
	scanf("%d", &T);
	while (T--){
		scanf("%d", &n);
		for (int i = 1; i <= n; i++)
			scanf("%d%d", &A[i], &D[i]);
		double p = 0, s[maxn] = { 0 };
		for (int i = 1; i <= n; i++)
			for (int j = 1; j <= n; j++) {
				if (A[i] >= 100 && A[j] >= 100) { s[j] += 0.5; continue; }
				int t1 = (int)(ceil((100.0 - A[i]) / A[i])) * D[i];
				int t2 = (int)(ceil((100.0 - A[j]) / A[j])) * D[j];
				if (t1 == t2)s[j] += 0.5;
				if (t1 > t2) s[j] += 1;
				if (t1 < t2) s[j] += 0;
			}
		p = s[1];
		for (int i = 2; i <= n; i++)
			if (p < s[i])p = s[i];
		printf("%f\n", p / n);
	}
	return 0;
}

6806 Equal Sentences

基础DP

#include
#include
#include
#include
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 5;
const ll mod = 1e9 + 7;
int T, n, cnt, a[maxn];
ll dp[maxn][2];
string tmp;
map<string, int>id;
int main(void) {
    scanf("%d", &T);
    while (T--){
        cnt = 0;
        scanf("%d", &n);
        id.clear();
        for (int i = 1; i <= n; i++) {
            cin >> tmp;
            if (!id.count(tmp))id[tmp] = ++cnt;
            a[i] = id[tmp];
            dp[i][0] = dp[i][1] = 0;
        }
        dp[1][0] = 1, dp[1][1] = 0;
        for (int i = 2; i <= n; i++) {
            dp[i][0] = dp[i - 1][1] + dp[i - 1][0] % mod;
            if (a[i] != a[i - 1])dp[i][1] = dp[i - 1][0] % mod;
            else dp[i][1] = 0;
        }
        printf("%lld\n", (dp[n][1] + dp[n][0]) % mod);
    }
    return 0;
}

6812 Kindergarten Physics

考虑到数据范围,最坏情况a=100,b=100,t0=100距离移动也不超过10^-6,因此直接输出d即可。

#include
using namespace std;
int T;
double a, b, d, t0;
int main(void) {
	scanf("%d", &T);
	while (T--){
		scanf("%lf%lf%lf%lf", &a, &b, &d, &t0);
		printf("%f\n", d);
	}
	return 0;
}

你可能感兴趣的:(ACM训练)