跳到正文

个人记录

8.28-河西校区

Leo_Luo_Xiaohei约 8 分钟
原文
文章信息与版本

文章信息

发布
2025年8月28日
收录
2025年12月12日
更新
2026年11月16日
篇幅
约 8 分钟

版本

  1. v1当前

8.28-河西校区

T1

U593675 查找数

思路

计算 A+BA+B ,边输入边查找

赛时代码&分数
Accepted1̸00pts\color{green}{Accepted\not100pts}
C++
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int a, b, c, d, e, f, g;
int ls, qs, lt, qt, lv, qv;
bool lr = 1, qr = 1;
signed main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> a >> b >> c >> d >> e >> f >> g;
	for (int i = 1; i <= g; i ++) {
		if (lr)	{
			lt ++;
			if (lt == a) 
				lr = 0;
		} else {
			ls ++;
			if (ls == c) 
				lr = 1;
		}
		if (qr)	{
			qt ++;
			if (qt == d) 
				qr = 0;
		} else {
			qs ++;
			if (qs == f) 
				qr = 1;
		}
	}
	lv = lt * b;
	qv = qt * e;
	cout << (lv == qv ? "Draw" : (lv < qv ? "Aoki" : "Takahashi"));
	return 0;
}
T2

U593858 数叉叉

思路

直接对于每个斜对角和自己都是 # 的位置,查找其左上有几个 # 即可。

赛时代码&分数
Accepted1̸00pts\color{green}{Accepted\not100pts}
C++
#include <bits/stdc++.h>
using namespace std;
const int N = 105;
const int _[] = {1, -1};
struct __ {
	int _1, _2, _3;
};
int h, w;
int a[N << 1];
char c[N][N];
int vis[N];
void f(int x, int y) {
	int cnt = 0;
	for (; c[x - 1][y - 1] == '#'; ) {
		x --;
		y --;
		cnt ++;
	}
	a[cnt] ++;
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> h >> w;
	for (int i = 1; i <= h; i ++) 
		for (int j = 1; j <= w; j ++) 
			cin >> c[i][j];
	for (int i = 1; i <= h; i ++) 
		for (int j = 1; j <= w; j ++) 
			if (c[i][j] == '#' && c[i - 1][j - 1] == '#' && c[i - 1][j + 1] == '#' && c[i + 1][j - 1] == '#' && c[i + 1][j + 1] == '#') 
				f(i, j);
	int n = min(h, w);
	for (int i = 1; i <= n; i ++) 
		cout << a[i] << " ";
	return 0; 
}
T3

U593859 落落的去的数学问题六()

思路

埃式筛质数,然后三层循环暴力枚举可能的情况

赛时得分
Unaccepted6̸pts\color{red}{Unaccepted\not6pts}
正解
C++
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e7 + 5;
ll n, top, ans;
ll f[N];
ll o[N];
void gp(ll n) {
    for (ll i = 2; i <= n; i ++) {
        if (f[i]) 
            continue;
        o[++ top] = i;
        for (ll j = 2; i * j <= n; j ++) 
            f[i * j] = 1;
    }
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
    cin >> n;
    gp(sqrt(n));
    for (ll i = 1; i <= top; i ++) {
        if (o[i] * o[i] * o[i] * o[i] * o[i] > n) 
            break;
        for (ll j = i + 1; j <= top; j ++) {
            ll b = o[j];
            if (o[i] * o[i] * o[j] * o[j] * o[j] > n) 
                break;
            for (ll k = j + 1; k <= top; k ++) {
                ll c = o[k];
                if (o[i] * o[i] * o[j] * o[k] * o[k] > n) 
                    break;
                ans ++;
            }
        }
    }
    cout << ans;
	return 0;
}
T4

U593866 更多的o

思路

前缀和+二分查找+分段思考

赛时得分
Unaccepted0̸pts\color{red}{Unaccepted\not0pts}
正解
C++
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1.5e6 + 5;
char c;
ll n, m, k;
ll a[N * 2], b[N * 2];
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
    cin >> n >> m >> k;
    for (int i = 1; i <= n; i ++) {
        cin >> c;
        if (c == 'x') 
            a[i] = 1;
        else 
            a[i] = 0;
        a[i + n] = a[i];
    }
    for (int i = 1; i <= n * 2; i ++) 
        b[i] = b[i - 1] + a[i];
    ll ans = (k / b[n]) * n;
    m -= k / b[n];
    if (m == 0) {
        cout << ans;
        return 0;
    }
    k %= b[n];
    ll sum = 0;
    for (ll l = 1, r; l <= n; l ++) {
        ll x = k + b[l - 1];
        r = upper_bound(b + l, b + n * 2 + 1, x) - b;
        if (m == 1) 
            sum = max(sum, min(r, n) - l);
        else 
            sum = max(sum, r - l);
    }
    cout << ans + sum;
	return 0;
}
原文