2022年浙江理工大学校赛同步赛

酶和ATP 2022年03月27日 674次浏览

中午十二点开始,持续五个小时!对于只会签到题的我很是难受。

问题 A: 搭台子

题目描述
浙江理工大学沈炜教授协助警方智破骗局,挽回27.73亿。
沈老师很低调,但他的研究生却要高调一下,所以他们准备在浙江理工大学图书馆前的大广场上搭一个正方体的台子,然后站在上高歌一曲,以做祝贺。
现在有无限根长度为 1的木棍,我们现在需要用这些木棍来搭建一个正方体框架。一个正方体有 12条边,所以搭建一个边长为 1 的正方体框架需要 12 根木棍。然而搭建一个边长为 2的正方体需要 8 个边长为 1的正方体拼起来,这样有一些边会重合,所以一个边长为 2的正方体需要 54个木棍。求拼成一个边长为 x的正方体框架需要多少根木棍。
输入
一行,输入一个数字 x(1≤x≤106),表示需要拼成正方体框架的边长。
输出
一行,输出所需要的木棍个数。
【输入样例1】
1
【输入样例2】
2
【输出样例1】
12
【输出样例2】
54

显然样例有问题,1错了位置,不过画图找规律就好啦!

#include <algorithm>
#include <climits>
#include <cstring>
#include <iostream>
using namespace std;

typedef long long LL;

int main() {
    LL n;
    cin >> n;
    if (n == 1)
        cout << 12 << endl;
    else
        cout << n * (n + 1) * (n + 1) * 3 << endl;
    return 0;
}

问题 B: Scaling Recipe

题目描述
You’ve got a recipe which specifies a number of ingredients, the amount of each ingredient you will need, and the number of portions it produces. But, the number of portions you need is not the same as the number of portions specified in the recipe! How can you scale it?
输入
The first line of input contains three integers n (1 ≤ n ≤ 40), x and y (1 ≤ x, y ≤ 40,000), where n is the number of ingredients in the recipe, x is the number of portions that the recipe produces, and y is the number of portions you need. Each of the next n lines contains a single integer a (1 ≤ a ≤ 40,000). These are the amounts of each ingredient needed for the recipe. The inputs will be chosen so that the amount of each ingredient needed for y portions will be an integer.
输出
Output n lines. On each line output a single integer, which is the amount of that ingredient needed to produce y portions of the recipe. Output these values in the order of the input.
【样例输入1】
2 4 10
8
12
【样例输入2】
3 37627 38021
34571
38009
34189
【样例输出1】
20
30
【样例输出2】
34933
38407
34547

数据范围时候好像也有问题,我把 N 开到 500 就能 AC 了???

#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
using namespace std;

typedef long long LL;
const int N = 500;
LL n, x, y;
LL a[N];

int main() {
    cin >> n >> x >> y;
    for (int i = 0; i < n; i++) scanf("%lld", &a[i]);
    for (int i = 0; i < n; i++) printf("%lld\n", a[i] * y / x);
    return 0;
}

问题 E: Double Password

题目描述
A computer at ICPC headquarters is protected by a four-digit password—in order to log in, you normally need to guess the four digits exactly. However, the programmer who implemented the password check left a backdoor in the computer—there is a second four-digit password. If the programmer enters a four-digit sequence, and for each digit position the digit entered matches at least one of the two passwords in that same position, then that four-digit sequence will log the programmer into the computer. Given the two passwords, count the number of distinct four-digit sequences that can be entered to log into the computer.
输入
The input consists of exactly two lines. Each of the two lines contains a string s (|s| = 4, s ∈ {0-9} ∗ ). These are the two passwords.
输出
Output a single integer, which is the number of distinct four-digit sequences that will log the programmer into the system.
【样例输入1】
1111
1234
【样例输入2】
2718
2718
【样例输出1】
8
【样例输出2】
1

#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
using namespace std;

string a, b;
int ans;
int main() {
    cin >> a >> b;
    for (int i = 0; i < 4; i++)
        if (a[i] != b[i]) ans++;
    cout << pow(2, ans) << endl;
    return 0;
}

问题 J: 亚运会旗帜

题目描述
2022年亚运会在杭州举行。
浙江理工大学经常为这些大的赛事设计一些标识,上次冬运会就有浙江理工大学的设计。
亚运会开幕式,交给浙江理工大学一个旗帜设计,要求设计的旗帜有强烈的颜色反差感。
艺术设计学院的老师对颜色进行了设计,每个颜色对应一个数字,把第一次出现的n面旗帜用数组a表示,第2次出现的用数组b表示
A={a[1],a[2],…,a[n]},B={b[1],b[2],…,b[n]},从A、B中各选出n个元素进行一一配对(可以不按照原来在序列中的顺序),并使得所有配对元素差的绝对值之和最大。
输入
输入的第1行为1个整数n 第2行包含n个整数,题目中的A序列。 第3行包含n个整数,题目中的B序列。
输出
一个数,最大配对
样例输入
4
2 5 6 3
1 4 6 7
样例输出
14

和昨天的 F 题一脉相承,这叫贪心?

#include <algorithm>
#include <climits>
#include <cstring>
#include <iostream>
using namespace std;
const int N = 10010;

typedef long long LL;

bool cmp(LL a, LL b) { return a > b; }
LL n;
LL a[N], b[N];
LL ans;
int main() {
    scanf("%lld", &n);
    for (int i = 0; i < n; i++) scanf("%lld", &a[i]);
    for (int i = 0; i < n; i++) scanf("%lld", &b[i]);
    sort(a, a + n);
    sort(b, b + n, cmp);
    for (int i = 0; i < n; i++) ans += abs(a[i] - b[i]);
    printf("%lld\n", ans);
    return 0;
}