diff --git a/10xxx/10375.cpp b/10xxx/10375.cpp new file mode 100644 index 00000000..d3a871d5 --- /dev/null +++ b/10xxx/10375.cpp @@ -0,0 +1,35 @@ +#include +#include +#include +using namespace std; + +inline int calc(int x) { + int ret = 0; + while (x) ret += x % 10, x /= 10; + return ret; +} + +void solve(void) { + int n; cin >> n; + + vector a(100, 0), b(100, 0); + for (int i=1; i<=1e7; i++) { + int x = calc(i); + if (b[x]++ >= n) continue; + a[x] += i; + } + + long long ans = 1e18; + for (int i=0; i<100; i++) { + if (b[i] >= n) ans = min(ans, a[i]); + } + cout << ans; +} + +int main(void) { + ios::sync_with_stdio(false); + cin.tie(nullptr); + + solve(); + return 0; +} \ No newline at end of file