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个数. 给出一 ...
随机推荐
- Hibernate常用方法之_查询
1.使用session的get方法 public User getUser(int id){ Session session = null; User user = null; try { sessi ...
- Splunk学习与实践
一. Splunk公司与产品 美国Splunk公司,成立于2004年,2012年纳斯达克上市,第一家大数据上市公司,荣获众多奖项和殊荣.总部位于美国旧金山,伦敦为国际总部,香港设有亚太支持中心, ...
- 关于Maven项目install时出现No compiler is provided in this environment的处理
关于Maven项目build时出现No compiler is provided in this environment的处理 新配置的Eclipse环境,运行现有项目没问题,一日,从svn上检出了一 ...
- poj3133 Manhattan Wiring
Manhattan Wiring Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 2016 Accepted: 1162 ...
- 洛谷P1265 公路修建
P1265 公路修建 177通过 600提交 题目提供者该用户不存在 标签图论 难度普及+/提高 提交该题 讨论 题解 记录 最新讨论 long long类型赋值-1为什么… p党80的进 为什么不过 ...
- spring中<bean>中parent标签的使用
简介:spring 中parent标签是指:某个<bean>的父类.这个类可以覆盖parent的属性, 代码如下: Parent类的代码如下: package com.timo.domai ...
- Phantomjs设置浏览器useragent的方式
Selenium中使用PhantomJS,设置User-Agent的方法. 默认情况下,是没有自动设置User-Agent的:设置PhantomJS的user-agent def __init__(s ...
- 使用mysqldump命令备份恢复MySQL数据库
1.各种用法说明 A. 最简单的用法: mysqldump -uroot -pPassword [database name] > [dump file] 上述命令将指定数据库备份到某dump文 ...
- 使用HTML实现对汉字拼音的支持
<!DOCTYPE HTML><html> <head> <meta charset="utf-8"> <title>无 ...
- javascript实现倒计时(转)
<html> <head> <title>倒计时</title> <meta charset="utf-8"> < ...