跳到正文

个人记录

8.24-河西校区

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

文章信息

发布
2025年8月24日
收录
2025年12月12日
更新
2026年11月14日
篇幅
约 10 分钟

版本

  1. v1当前

8.24-河西校区

T1

T640711 快递费用

题意

某邮寄公司按物品重量和目的地区域收费。

重量标准为:

不足 500500 克 2020 元,超过 500500 克的,超重的部分按每 500500 克加收费用。超出的重量不足 500500 克的,按 500500 克计算。

目的地区域标准: 区域 11:每超重 500500 克加收 44 元;

区域 22:每超重 500500 克加收 66 元;

区域 33:每超重 500500 克加收 99 元;

区域 44:每超重 500500 克加收 1010 元;

区域 55:每超重 500500 克加收 1717 元。

思路

按照题意模拟即可。

赛时代码&得分
Accepted1̸00tps\color{green}{Accepted\not100tps}
C++
#include <bits/stdc++.h>
using namespace std;
int x, y, z = 20;
signed main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> x >> y;
	if (y == 1) 
		y = 4;
	else if (y == 2) 
		y = 6;
	else if (y == 3)
		y = 9;
	else if (y == 4) 
		y = 10;
	else 
		y = 17;
	x -= 500;
	while (x > 0) {
		x -= 500;
		z += y;
	} 
	cout << z;
	return 0;
}
T2

T638889 石头布没有剪刀

题意

你和对手都只有两种出拳方式:石头 g 和布p,规则一样,赢了得一分,平局不得分,输了减一分。 现给你对手的出拳方式,在对于任意位置 ii 满足你出过的石头的次数大于你出过的布的次数时,输出你能得到的最大分数。

赛时得分
Unaccepted0̸tps\color{red}{Unaccepted\not0tps}
思路

能出布就出布。

正解
C++
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
string s;
int cnt1, cnt2, sc;
signed main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> s;
	int n = s.size();
	for (int i = 0; i < n; i ++) 
        if (s[i] == 'g') 
            if (cnt1 == cnt2) 
                cnt1 ++;
            else {
                cnt2 ++;
                sc ++;
            }
        else 
            if (cnt1 == cnt2) {
                cnt1 ++;
                sc --;
            } else 
                cnt2 ++;
	cout << sc;
	return 0;
}
T3

T644252 篝火问题

题意

在一个二维平面上,原点存在一个篝火,会不停地在这一格产生烟雾。每秒都有风把烟雾吹向四方,风速一秒一格。

求在观测点 x,yx, y 是否有烟雾。

赛时得分

根本没写。

Unaccepted0̸tps\color{red}{Unaccepted\not0tps}
思路

由于一个一个模拟烟雾移动太费时间,故利用题目所说“求观测点是否有烟雾”和相对运动,只移动篝火和人。

正解
C++
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
map<pair<int, int>, bool> mp;
int n, r, c, x, y, _1, _2;
char C;
signed main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n >> r >> c;
    mp[{x, y}] = 1;
    for (int i = 1; i <= n; i ++) {
        cin >> C;
        if (C == 'N') {
            x ++;
            r ++;
        } else if (C == 'S') {
            x --;
            r --;
        } else if (C == 'W') {
            y ++;
            c ++;
        } else if (C == 'E') {
            y --;
            c --;
        }
        mp[{x, y}] = 1;
        if (mp.count({r, c})) 
            cout << 1;
        else 
            cout << 0;
    }
	return 0;
}
T4

T639146 落落的去的数学问题3

题意

定义 f(x,y)f(x, y) 如下:

将 x,yx, y 的十进制表示分别作为字符串解释,并按顺序连接,得到字符串 zz。将 zz 作为十进制整数解释,其值即为 f(x,y)f(x, y)。

给定一个长度为 NN 的正整数序列 A=(A1,…,AN)A=(A_1,\ldots,A_N)。请计算下式的值对 998244353998244353 取模的结果:

∑i=1N−1∑j=i+1Nf(Ai,Aj)\sum_{i=1}^{N-1}\sum_{j=i+1}^N f(A_i,A_j)
赛时得分

暴力。

Unaccepted1̸0tps\color{red}{Unaccepted\not10tps}
思路

对于每一个 2≤j≤n2 \le j \le n ,前缀和预处理所有 jj 之前的 aia_i ,统一做乘法运算。

正解
C++
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 5, mod = 998244353;
ll n, ans;
ll a[N], b[N];
int f(int x, int y) {
	string a = i2s(x), b = i2s(y);
	ll res = s2l(a + b);
	res %= mod;
	return res;
}
ll gtl(ll x) {
    ll cnt = 0;
    for (; x; cnt ++) 
        x /= 10;
    return cnt;
}
ll p(ll x) {
    ll res = 1;
    for (ll i = 1; i <= x; i ++) 
        res = (res * 10);
    return res % mod;
}
signed main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i ++) {
        cin >> a[i];
        b[i] = (b[i - 1] + a[i]) % mod;
    }
    for (int j = 2; j <= n; j ++) {
        ll len = gtl(a[j]);
        ans += (b[j - 1] * p(len)) % mod + ((j - 1) * (a[j] % mod)) % mod;
        ans %= mod;
    }
	cout << ans;
	return 0;
}
T5

P1100 高低位交换

题意

给出一个小于 2322^{32} 的非负整数。这个数可以用一个 3232 位的二进制数表示(不足 3232 位用 00 补足)。我们称这个二进制数的前 1616 位为“高位”,后 1616 位为“低位”。将它的高低位交换,我们可以得到一个新的数。试问这个新的数是多少(用十进制表示)。

思路

利用位运算和 unsigned 类型,取其前十六位和后十六位,相加即可。

赛时得分&代码
Accepted1̸00tps\color{green}{Accepted\not100tps}
C++
#include <bits/stdc++.h>
#define u unsigned
using namespace std;
const int N = 2e5 + 5;
u x, y, z;
signed main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> x;
	y = x >> 16;
	z = x << 16;
	cout << y + z;
	return 0;
}
原文