【CF 1104A】Splitting into digits
A. Splitting into digits
Vasya has his favourite number nn. He wants to split it to some non-zero digits. It means, that he wants to choose some digits d1,d2,…,dkd1,d2,…,dk, such that 1≤di≤91≤di≤9 for all ii and d1+d2+…+dk=nd1+d2+…+dk=n.
Vasya likes beauty in everything, so he wants to find any solution with the minimal possible number of different digits among d1,d2,…,dkd1,d2,…,dk. Help him!
Input
The first line contains a single integer nn — the number that Vasya wants to split (1≤n≤10001≤n≤1000).
Output
In the first line print one integer kk — the number of digits in the partition. Note that kk must satisfy the inequality 1≤k≤n1≤k≤n. In the next line print kk digits d1,d2,…,dkd1,d2,…,dk separated by spaces. All digits must satisfy the inequalities 1≤di≤91≤di≤9.
You should find a partition of nn in which the number of different digits among d1,d2,…,dkd1,d2,…,dk will be minimal possible among all partitions of nn into non-zero digits. Among such partitions, it is allowed to find any. It is guaranteed that there exists at least one partition of the number nn into digits.
Examples
input
1
output
1
1
input
4
output
2
2 2
input
27
output
3
9 9 9
将n拆分成若干个数,保证这些数字的种类尽可能少。
实际上全部拆分成 1 就行了,只需要1种类型的数字
代码:
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
using namespace std;
#define ll long long
#define inf 0x3f3f3f3f
#define mem(a,b) memset(a,b,sizeof(a))
#define closeio std::ios::sync_with_stdio(false)
int main()
{
int n;
cin>>n;
cout<<n<<endl;
while(n--)
{
cout<<1;
if(n)
cout<<" ";
}
return 0;
}