题目链接
题目大意
(t(tle100))组数据
(s(sle min(n,100)))个数的和为(n(nle1e9))
要让(s)个数从(10)进制变为(11)进制的和的最大
输出(s)个数
题目思路
其实就是贪心的思维
要进位尽可能的少
例如10个1 和1个10的值在11进制下是不同的
实现的话我看了一下rk2的实现是真的很简单 而且复杂度只有(O(ts))
代码
#include<bits/stdc++.h>
#define fi first
#define se second
#define debug cout<<"I AM HERE"<<endl;
using namespace std;
typedef long long ll;
const int maxn=14+5,inf=0x3f3f3f3f,mod=1e9+7;
const double eps=1e-6;
int s,n;
signed main(){
int _;cin>>_;
while(_--){
cin>>s>>n;
vector<int> ans;
for(int x=1e9;x>=1;x/=10){
if(n==1){
ans.push_back(s);
break;
}
if(s-x<n-1) continue;
ans.push_back(x);
s-=x;
n--;
x=x*10;
}
for(auto i:ans){
cout<<i<<" ";
}
cout<<'
';
}
return 0;
}