0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-12-28 12:31:59 +00:00

E - Addition and Multiplication 2

https://atcoder.jp/contests/abc257/submissions/32744514
This commit is contained in:
Baoshuo Ren 2022-06-25 21:27:58 +08:00
parent d858d4e65a
commit fe3caadd4a
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A

49
AtCoder/ABC257/E/E.cpp Normal file
View File

@ -0,0 +1,49 @@
#include <iostream>
using std::cin;
using std::cout;
const char endl = '\n';
const int N = 1e6 + 5;
int n, a[N], c[10], min, max;
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n;
min = 1;
for (int i = 1; i <= 9; i++) {
cin >> c[i];
if (c[i] <= c[min]) min = i;
}
max = n / c[min];
for (int i = 1; i <= max; i++) {
a[i] = min;
}
n %= c[min];
for (int i = max; i; i--) {
for (int j = 9; j > min; j--) {
if (n >= c[j] - c[min]) {
n -= c[j] - c[min];
a[i] = j;
break;
}
}
}
for (int i = max; i; i--) {
cout << a[i];
}
cout << endl;
return 0;
}