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 }

 

posted @ 2019-01-23 17:36  SaltyFishQF  阅读(321)  评论(0编辑  收藏  举报