【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;
}

 

全部评论

相关推荐

(黑话警告⚠️:hc=岗位数量,&nbsp;mt=导师,&nbsp;ld=直属领导,&nbsp;cr=代码审查)25年1月,我加入了字节某前端团队,并期望能在这里待到秋招并尝试转正。然而,就在上周,ld&nbsp;找我1v1,告诉我,我的能力和团队预期不太匹配,并和我劝退。晴天霹雳吗?肯定是有的。那一刻,脑子里嗡嗡作响,各种情绪翻涌。但冷静下来想想,这几个月,自己在能掌控的范围内,确实有不少地方做得不尽如人意。所以,我想把这段不算成功的经历复盘一下,希望能给同样在努力转正的你提个醒,避开我踩过的坑。一、ld&nbsp;的要求要注意刚进组时,ld就和我聊过转正的事。我当时发问:“咱们这儿有hc&nbsp;吗?”&nbsp;ld没直接回答,只是说:“看能力,能力到了...
牛客上的彭于晏:过来人告诉你,入职后要做的第一件事儿不是说主动找活儿做,你要先学会融入团队,摸清ld的性格,投其所好。然后才是展示你的能力,能力上可以说技术或者业务,以业务能力为主,技术能力为辅。优先保证自己对业务需求的开发保证质量效率,然后再谈技术的问题,不要你觉得啥啥啥不行就想着整体优化了(发现校招生最喜欢干这事儿),我工作快5年了发现搞这种的最后都没啥好的结果,产出没有还引入新的bug,校招或者实习的水平看到的问题别人看不到嘛?为什么别人不去搞?浪费时间还没收益的事儿不要去做,技术上的能力体现在对于一个新需求,在不符合现在业务发展的架构设计上,你能拿出好的技术方案同时能考虑到后续业务发展逐渐将技术架构引入合理的架构,这是一个漫长的过程而不是一次性的
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务