[哥俩好数字] ADPC

时间:2021-03-16 13:51:43   收藏:0   阅读:0

技术图片

 

 

 

 

技术图片

 

 

 

 

 

 

 

技术图片
 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

 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!