Skip to content

Commit

Permalink
Add 10375.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
Hiyabye committed Jul 6, 2024
1 parent b43b4b9 commit 0a5a9e2
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions 10xxx/10375.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include <algorithm>
#include <iostream>
#include <vector>
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<long long> 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;
}

0 comments on commit 0a5a9e2

Please sign in to comment.