Splitting into digits CodeForce#1104A

题目链接:Splitting into digits 

题目原文

Vasya has his favourite number ?n. He wants to split it to some non-zero digits. It means, that he wants to choose some digits ?1,?2,,??d1,d2,…,dk, such that 1??91≤di≤9 for all ?i and ?1+?2++??=?d1+d2+…+dk=n.

Vasya likes beauty in everything, so he wants to find any solution with the minimal possible number of different digits among ?1,?2,,??d1,d2,…,dk. Help him!

思路

一开始想的有点复杂,后来一看题目最下面的Note

In the second test, there are 33 partitions of the number 44 into digits in which the number of different digits is 11. 
This partitions are [1,1,1,1][1,1,1,1], [2,2][2,2] and [4][4]. Any of these partitions can be found.
And, for example, dividing the number 44 to the digits [1,1,2][1,1,2] isn't an answer, because it has 22 different digits, that isn't the minimum possible number.

发现原来[1, 1, 1, 1]也算一组。于是就想是不是只要输出全1就行了,结果就AC了。

题解

 1 #include <iostream>
 2 #include <cstring>
 3 
 4 using namespace std;
 5 
 6 int main(int argc, char const *argv[])
 7 {
 8     int n;
 9     cin >> n;
10     cout << n << endl;
11     for(int i = 0; i < n; i++)
12     {
13         cout << "1 " ;
14     }
15     return 0;
16 }

 

转载于:https://www.cnblogs.com/SaltyFishQF/p/10310367.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值