提出番号 | 2385 |
---|---|

提出者 | kya |

言語 | C++ |

提出日時 | 2020-04-29 11:41:50 |

問題名 | (72)K-th DigitSum |

結果 | WA |

点数 | 0% |

テストケース | 結果 | 得点 | 実行時間 | メモリ使用量 |
---|---|---|---|---|

1 | WA | 0% | 24ms | 36752KB |

2 | AC | 100% | 17ms | 36752KB |

3 | WA | 0% | 17ms | 36768KB |

4 | WA | 0% | 18ms | 36768KB |

5 | WA | 0% | 17ms | 36752KB |

6 | WA | 0% | 17ms | 36768KB |

7 | WA | 0% | 17ms | 36768KB |

8 | WA | 0% | 17ms | 36752KB |

9 | AC | 100% | 17ms | 36752KB |

10 | AC | 100% | 17ms | 36768KB |

11 | WA | 0% | 16ms | 36752KB |

12 | WA | 0% | 17ms | 36768KB |

13 | WA | 0% | 18ms | 36768KB |

14 | WA | 0% | 17ms | 36768KB |

15 | WA | 0% | 17ms | 36768KB |

16 | WA | 0% | 16ms | 36752KB |

17 | AC | 100% | 17ms | 36768KB |

18 | AC | 100% | 17ms | 36752KB |

19 | WA | 0% | 17ms | 36752KB |

20 | WA | 0% | 18ms | 36768KB |

21 | WA | 0% | 18ms | 36768KB |

22 | WA | 0% | 18ms | 36768KB |

23 | AC | 100% | 17ms | 36768KB |

24 | WA | 0% | 18ms | 36752KB |

25 | WA | 0% | 18ms | 36768KB |

26 | WA | 0% | 16ms | 36768KB |

27 | AC | 100% | 17ms | 36752KB |

28 | WA | 0% | 17ms | 36752KB |

29 | WA | 0% | 16ms | 36768KB |

30 | WA | 0% | 16ms | 36752KB |

31 | WA | 0% | 16ms | 36768KB |

32 | WA | 0% | 17ms | 36768KB |

33 | AC | 100% | 17ms | 36752KB |

34 | WA | 0% | 17ms | 36752KB |

35 | WA | 0% | 17ms | 36768KB |

36 | WA | 0% | 18ms | 36768KB |

37 | AC | 100% | 16ms | 36752KB |

38 | WA | 0% | 17ms | 36768KB |

39 | WA | 0% | 17ms | 36768KB |

40 | WA | 0% | 16ms | 36768KB |

41 | WA | 0% | 16ms | 36768KB |

42 | WA | 0% | 17ms | 36768KB |

43 | WA | 0% | 17ms | 36768KB |

44 | WA | 0% | 17ms | 36768KB |

45 | AC | 100% | 18ms | 36752KB |

46 | AC | 100% | 17ms | 36752KB |

47 | WA | 0% | 17ms | 36752KB |

48 | WA | 0% | 18ms | 36768KB |

49 | WA | 0% | 17ms | 36768KB |

50 | WA | 0% | 17ms | 36752KB |

51 | AC | 100% | 17ms | 36752KB |

```
#include <bits/stdc++.h>
using namespace std;
constexpr int MAX_N = 1010;
constexpr int MAX = 1010;
int main() {
int n;
long long k;
cin >> n >> k;
long long dp[MAX][MAX_N] = {};
for (int i = 0; i < 10; i++) dp[1][i] = 1;
for (int i = 2; i < MAX; i++) {
for (int j = 0; j < MAX_N; j++) {
for (int d = 0; d < 10; d++) {
if (j - d >= 0) dp[i][j] += dp[i - 1][j - d];
}
}
}
int id = 0;
while (dp[id][n] <= k) id++;
vector<int> ans;
for (int i = 1; i < 10; i++) if (n - i >= 0) {
if (dp[id - 1][n - i] < k) k -= dp[id - 1][n - i];
else { ans.emplace_back(i); n -= i; break; }
}
auto solve = [&] () -> void {
for (int i = 0; i < 10; i++) if (n - i >= 0) {
if (dp[id - 1][n - i] < k) k -= dp[id - 1][n - i];
else { ans.emplace_back(i); n -= i; return; }
}
};
while (id--) solve();
for (const int &d : ans) cout << d; cout << n << '\n';
return 0;
}
```