题目来源: 2022 ICPC Asia EC 网络赛第一场: J. Gachapon

题面

题面施工中……

题解

题解施工中……

代码实现

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <bits/stdc++.h>
using namespace std;

int gcd(int a, int b)
{
return b ? gcd(b, a % b) : a;
}

int main()
{
int x, y;
cin >> x >> y;
const int n = 10000;
vector<int> uq(x);
uq[0] = n;
int sum = n;
for (int i = 1; i < x; ++i)
{
uq[i] = x - i;
sum += uq[i];
}
int target = n * y;
for (int i = 1; i < x; ++i)
{
int maxuq = uq[i - 1] - 1;
int maxadd = maxuq - uq[i];
int taradd = target - sum;
if (taradd > maxadd)
{
uq[i] = maxuq;
sum += maxadd;
}
else
{
uq[i] += taradd;
sum += taradd;
break;
}
}
for (int i = 0; i < x - 1; ++i)
{
int up = uq[i + 1];
int dp = uq[i];
up = dp - up;
int gp = gcd(up, dp);
up /= gp;
dp /= gp;
cout << up << " " << dp << "\n";
}
cout << "1 1";
return 0;
}