题目传送门
1 /*
2 构造水题:对于0的多个位数的NO,对于位数太大的在后面补0,在9×k的范围内的平均的原则
3 */
4 #include <cstdio>
5 #include <algorithm>
6 #include <cstring>
7 #include <cmath>
8 using namespace std;
9
10 const int MAXN = 1e3 + 10;
11 const int INF = 0x3f3f3f3f;
12 int a[MAXN];
13
14 int main(void) //Codeforces Round #206 (Div. 2) A. Vasya and Digital Root
15 {
16 //freopen ("A.in", "r", stdin);
17 int k, d;
18 while (scanf ("%d%d", &k, &d) == 2)
19 {
20 if (d == 0 && k > 1) {puts ("No solution"); continue;}
21 if (k >= d)
22 {
23 for (int i=1; i<=d; ++i) putchar ('1');
24 for (int i=1; i<=k-d; ++i) putchar ('0');
25 puts ("");
26 }
27 else
28 {
29 if (9 * k < d) {puts ("No solution"); continue;}
30 for (int i=1; i<=k; ++i) a[i] = d / k;
31 int res = d % k;
32 for (int i=1; i<=res; ++i) a[i]++;
33 for (int i=1; i<=k; ++i) printf ("%d", a[i]);
34 puts ("");
35 }
36
37 }
38
39 return 0;
40 }