Quasi Binary
思路
对答案k还是挺显然的,等于n的最大数位,
能想到这一点就简单了,只要存下所有的数位,然后一位一位模拟即可。
代码
/*
Author : lifehappy
*/
#include <bits/stdc++.h>
using namespace std;
int num[10], m, n, tot;
int main() {
// freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
cin >> n;
while(n) {
m = max(m, n % 10);
num[tot++] = n % 10;
n /= 10;
}
cout << m << "\n";
for(int i = 1; i <= m; i++) {
int ans = 0;
for(int j = tot - 1; j >= 0; j--) {
ans = ans * 10 + (num[j]-- > 0);
}
cout << ans << " \n"[i == m];
}
return 0;
} 
京公网安备 11010502036488号