Codeforces 538 B. Quasi Binary
2 seconds
256 megabytes
standard input
standard output
A number is called quasibinary if its decimal representation contains only digits 0 or 1. For example, numbers 0, 1, 101, 110011 — are quasibinary and numbers 2, 12, 900 are not.
You are given a positive integer n. Represent it as a sum of minimum number of quasibinary numbers.
The first line contains a single integer n (1 ≤ n ≤ 106).
In the first line print a single integer k — the minimum number of numbers in the representation of number n as a sum of quasibinary numbers.
In the second line print k numbers — the elements of the sum. All these numbers should be quasibinary according to the definition above, their sum should equal n. Do not have to print the leading zeroes in the numbers. The order of numbers doesn't matter. If there are multiple possible representations, you are allowed to print any of them.
9
9
1 1 1 1 1 1 1 1 1
32
3
10 11 11
题意就是把一个数用0,1组成的数来代替,让这些数的和为这个数。
代码:
#include<bits/stdc++.h>
using namespace std;
int a,b,i,m,t=1,g[10];
int main(){
cin>>a;
while(a){
b=a%10;
for(i=9;i>9-b;i--)
g[i]+=t;
if(b>m) m=b;
t*=10;
a/=10;
}
cout<<m<<endl;
for(i=0;i<10;i++){
if(g[i])
cout<<g[i]<<" ";
}
return 0;
}
Codeforces 538 B. Quasi Binary的更多相关文章
- Codeforces Round #300 Quasi Binary(DP)
Quasi Binary time limit per test 2 seconds memory limit per test 256 megabytes input standard input ...
- Codeforces Round #300 B. Quasi Binary 水题
B. Quasi Binary Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/538/probl ...
- Codeforces 538 F. A Heap of Heaps
\(>Codeforces \space 538 F. A Heap of Heaps<\) 题目大意 :给出 \(n\) 个点,编号为 \(1 - n\) ,每个点有点权,将这些点构建成 ...
- B. Quasi Binary
开启博客园 记录codeforces程序 这个题目很简单 一个数能被最少的只包含0 ,1的数字和 如:9 = 1+1+1+1+1+1+1+1+1 10 =10 12 =11+ 1 求得是最少个数的整数 ...
- Codeforces 551D GukiZ and Binary Operations(矩阵快速幂)
Problem D. GukiZ and Binary Operations Solution 一位一位考虑,就是求一个二进制序列有连续的1的种类数和没有连续的1的种类数. 没有连续的1的二进制序列的 ...
- 【Codeforces Round 1114】Codeforces #538 (Div. 2)
Codeforces Round 1114 这场比赛做了\(A\).\(C\).\(D\).\(E\),排名\(134\). \(B\)题做了很长时间,好不容易最后一分钟\(Pretest\ Pass ...
- Codeforces 538 A. Cutting Banner-substr()函数字符串拼接
A. Cutting Banner time limit per test 2 seconds memory limit per test 256 megabytes input standa ...
- Codeforces 1237E Perfect Balanced Binary Search Tree
题目链接 Observations 含有 $n$ 个点且 key(以下也称 key 为「权值」)是 1 到 $n$ 的 BST 具有下列性质: 若 $k$ 是一个非根叶子且是个左儿子,则 $k$ 的父 ...
- codeforces 400E. Inna and Binary Logic 线段树
题目链接 给出n个数, 定义a[1][i]为这初始的n个数, 然后a[i][j] = a[i-1][j]&a[i-1][j-1], 这样就可以得到一个三角形一共n*(n-1)/2个数. 给出一 ...
随机推荐
- 颜色采集器colpick Color Picker
简单 RGB.HSB.十六进制颜色选取器 jQuery 插件. 非常直观类似 Photoshop 的界面. 光明和黑暗很容易自定义 CSS3 外观. 28 KB 总由浏览器加载看起来不错甚至在 IE7 ...
- 用JavaScript写一个类似PHP print_r的函数
PHP print_r的函数很好用,可以用来打印数组.对象等的结构与数据,可惜JavaScript并没有原生提供类似的函数.不过我们可以试着自己来实现这个函数,下面提供一些方法与思路. 方法一 fun ...
- cookie中的path与domain属性详解
1.domain表示的是cookie所在的域,默认为请求的地址,如网址为www.jb51.net/test/test.aspx,那么domain默认为www.jb51.net.而跨域访问,如域A为t1 ...
- Maven如何打包本地依赖包
有的jar包,在maven中心库里面是没有的,那么,如何在项目中使用呢? 假设我们需要使用:apache-ant-zip-2.3.jar 将该jar包,放在项目的lib目录,例如: 在pom.xml里 ...
- word公式编辑中的转义字符
Some of the commonly used symbols: \infty - Infinity \leq - Less then or equal \geq - ...
- 动态性能视图v$session_longops
v$session_longops This view displays the status of various operations that run for longer than 6 sec ...
- javascript学习教程
我来班门弄斧一下吧,把我JavaScript学习过程中常去的一些网站分享给大家: =========================增加================================ ...
- HDU2571--命运---DP
http://acm.hdu.edu.cn/showproblem.php?pid=2571 #include "iostream" #include "cstdio&q ...
- python读写Excel文件_xlrd模块读取,xlwt模块写入
一.安装xlrd模块和xlwt模块(服务器) 1. 下载xlrd模块和xlwt模块 到python官网http://pypi.python.org/pypi/xlrd下载模块.下载的文件例如:xlrd ...
- 【uva10829-求形如UVU的串的个数】后缀数组+rmq or 直接for水过
题意:UVU形式的串的个数,V的长度规定,U要一样,位置不同即为不同字串 https://uva.onlinejudge.org/index.php?option=com_onlinejudge&am ...