贪心 Codeforces Round #300 A Cutting Banner
2024-08-27 20:43:12
/*
贪心水题:首先,最少的个数为n最大的一位数字mx,因为需要用1累加得到mx,
接下来mx次循环,若是0,输出0;若是1,输出1,s[j]--;
注意:之前的0的要忽略
*/
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
using namespace std; const int MAXN = 1e4 + ;
const int INF = 0x3f3f3f3f; int main(void) //Codeforces Round #300 A Cutting Banner
{
//freopen ("B.in", "r", stdin); char s[];
while (scanf ("%s", &s) == )
{
int len = strlen (s);
int mx = -;
for (int i=; i<len; ++i) mx = max (mx, s[i] - ''); printf ("%d\n", mx);
for (int i=; i<=mx; ++i)
{
bool ok = false;
for (int j=; j<len; ++j)
{
if (s[j] == '')
{
if (!ok) continue;
else printf ("");
}
else
{
ok = true;
printf (""); s[j]--;
}
}
if (i < mx) printf (" ");
}
puts ("");
} return ;
}
最新文章
- 《笨办法学C》笔记之指针
- plsql 查询结果窗口 不正常
- Csharp: read excel file using Open XML SDK 2.5
- 【读书笔记】iOS-KVC
- LU分解,Javascript代码
- Android视频直播解决方案(rstp、udp)
- MYSQL 删除字段值为NULL的语法
- 【转】SQLServer内部原理
- div+css之清除浮动
- [ActionScript 3.0] AS3 实现XML转换成JSON
- Windbg 进程与线程 《第三篇》
- Esper系列(十三)Splitting and Duplicating Streams
- 实例分析jdom和dom4j的使用和区别
- 学习Swift -- 错误处理
- static关键字使用
- c++自带倒置数组函数
- ZOJ 3702 Gibonacci number(数学推导)
- SVM原理以及Tensorflow 实现SVM分类(附代码)
- Spark2.2.0分布式集群安装(StandAlone模式)
- C#学习笔记-XML的读写(一)
热门文章
- 以DDD为开发模式的设计开发步骤可以是
- (转载)解决ListView中使用EditText所遇到的一些冲突
- hiho一下 第九十六周 数论五&#183;欧拉函数
- 数学复习 ---- Mathematics Notes: A Programmer&#39;s Perspective ---- by Orzer ---- 我是沙茶
- Balanced Teams (USACO Jan Bronze 2014)
- Having与Where的区别
- Mybatis 动态sql标签
- css行内样式
- HDU4870 Rating(概率)
- DisJSet:食物链(POJ 1182)