Start: Jun, 05, 2019 17:00:00
2019春ACM通识课考试(第三场)
End: Jun, 05, 2019 20:15:00
Time elapsed:
Time remaining:

Problem_ID: E
Result: Accepted
Time: 721ms
Memory: 9524kB
Author: Hujia
In contest: 1272

#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <iomanip>
using namespace std;
typedef long long LL;
const int maxn=1e6;
const int inf = 0x3f3f3f3f;
struct num{
	int i,cnt;
	num(int a=0){
		i=a;
		cnt=0;
		while(a){
			cnt+=a%10;
			a/=10;
		}
	}
	bool operator <(const num &a)const{
		return cnt!=a.cnt?cnt<a.cnt:i<a.i;
	}
}s[1000000];
int main()
{
	for(int i=0;i<1000000;++i)
		s[i]=num(i);
	sort(s,s+1000000);
	for(int i=0;i<1000000;++i)
		printf("%06d\n",s[i].i);
}