[哥俩好数字] ADPC

 

 

 

 

 

 

 

 

 

 

 

 1 #include <iostream>
 2 using namespace std;
 3 
 4 long long  f(int x )
 5 {
 6     long long  tot = 0;
 7     while(x)
 8     {
 9         tot += x % 10;
10         x /= 10;
11     }
12     return tot;
13 }
14 
15 int n , cnt[500];
16 long long sum[500];
17 long long ans = 1e18;
18 
19 int main()
20 {
21     cin >> n ;
22     for(int i = 1; i<= 600000; i++)
23     {
24         int x = f(i);
25         if(cnt[x] < n )
26         {
27             cnt[x]++;
28             sum[x] +=i;
29             
30         }
31         if(cnt[x] == n )
32         ans = min(ans, sum[x]);
33         
34     }
35     printf("%lld",ans);
36     
37     
38  
39   
40   return 0;
41 }
题解 View Code

 

posted @ 2021-03-14 23:15  Leo-aiolia-bao  阅读(38)  评论(0)    收藏  举报