1727. Znaika's Magic Numbers
来源:互联网 发布:索尼as200 软件 编辑:程序博客网 时间:2024/06/06 09:56
原题链接: http://acm.timus.ru/problem.aspx?space=1&num=1727
//使用 C# 语言解答如下:using System;// http://acm.timus.ru/problem.aspx?space=1&num=1727static class Timus{ static void Main() { int n = int.Parse(Console.ReadLine()); int count = Compute(ref n), tops = count; for (int i = 0; n > 9; i++, n -= 10) count++; int tens = count - tops; Console.WriteLine(count += ((n > 0) ? 1 : 0)); for (int i = 99999; tops-- > 0; i--) Console.Write(i + " "); while (tens-- > 0) Console.Write("19 28 37 46 ".Substring(tens * 3, 3)); if (n > 0) Console.Write(n); } static int Compute(ref int n) { int count = 0; for (int sum = 45; n >= 45; ) { n -= sum--; if (++count % 10 == 0) sum += 9; if (count % 100 == 0) sum += 9; if (count % 1000 == 0) sum += 9; } return count; }}
1727. Znaika's Magic Numbers
Time limit: 0.5 second
Memory limit: 64 MB
Memory limit: 64 MB
Znaika has many interests. For example, now he is investigating the properties of number sets. Znaika writes down some set consisting of different positive integers (he calls this set a generating set), calculates the sum of all the written digits, and writes down the result in a special notebook. For example, for a generating set 7, 12, 43, he will write down the number 17 = 7 + 1 + 2 + 4 + 3 . Znaika is sure that only magic numbers can appear as a result of this operation.
Neznaika laughs at Znaika. He thinks that there is a generating set for every number, and he even made a bet with Znaika that he would be able to construct such a set.
Help Neznaika win the bet and construct a generating set for a given number.
Input
The only input line contains an integer n (0 < n < 105).
Output
If it is possible to construct a generating set for the number n, output the number of elements in this set in the first line. In the second line output a space-separated list of these elements. The elements of the set must be different positive integers strictly less than 105. If there are several generating sets, output any of them. If there are no generating sets, output −1.
Sample
17
37 12 43
Problem Author: Ivan Burmistrov
Problem Source: Ural Regional School Programming Contest 2009
Problem Source: Ural Regional School Programming Contest 2009
Tags: none
- 1727. Znaika's Magic Numbers
- URAL 1727. Znaika's Magic Numbers(数学 vector)
- Magic Numbers
- A. Magic Numbers
- CF_320A.Magic Numbers
- A. Magic Numbers
- UVa:471 Magic Numbers
- UVA - 471 Magic Numbers
- UVA471- Magic Numbers
- Notable magic numbers
- UVa 471 - Magic Numbers
- Magic Numbers CodeForces
- codeforces 320A. Magic Numbers
- codeforces-320A-Magic Numbers
- CodeForces--320A--Magic numbers
- UVa 471 Magic Numbers (枚举)
- codeforces 628D Magic Numbers
- Codeforces 628D Magic Numbers
- 设计模式之结构模式
- unity自动保存项目
- 通用Dao 设计 2
- Pull解析器解析xml(Android)
- TCP详解----多路复用与多路分解(一)
- 1727. Znaika's Magic Numbers
- Java中的关键字
- 并发程序设计-java.util.concurrent介绍
- vs2003迁移到vs2010
- 命题空间的全局变量不能直接拖到Watch窗口查看
- hdu1065-I Think I Need a Houseboat
- LogBack配置及注意事项
- jsp 之间参数传递乱码问题
- hdu 3791 二叉搜索树 叉排