题意: 给你 数的长度 m, 数的每个数的和 Sum;

输出 这个数最小值 和最大值

#include<bits/stdc++.h>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int Sum, m;
cin >> m >> Sum;
int tmp = Sum;
if(Sum > m*9 || (m > 1 && Sum == 0)) printf("-1 -1\n");
else
{
string ans = "";
for(int i = 0; i < m; ++i)
{
for(int d = 0; d < 10; ++d)
{
if((d > 0 || i > 0 || (m == 1 && d == 0)) && Sum >= d && Sum <= 9*(m-i-1)+d)
{
ans += char(d + '0');
Sum -= d;
break;
}
}
}
cout << ans << " ";
ans = "";
Sum = tmp;
for(int i = 0; i < m; ++i)
{
for(int d = 9; d >= 0; --d)
{
if(Sum >= d && Sum <= 9*(m-i-1)+d)
{
ans += char(d + '0');
Sum -= d;
break;
}
}
}
cout << ans <<endl;
}
return 0;
}

  

CF 489C 暴力处理的更多相关文章

  1. B. Lost Number【CF交互题 暴力】

    B. Lost Number[CF交互题 暴力] This is an interactive problem. Remember to flush your output while communi ...

  2. CF #305 (Div. 2) C. Mike and Frog(扩展欧几里得&&当然暴力is also no problem)

    C. Mike and Frog time limit per test 1 second memory limit per test 256 megabytes input standard inp ...

  3. [ 9.11 ]CF每日一题系列—— 441C暴力模拟

    Description: n * m 的地图,建设k个管道管道只能横竖走,且长度大于等于2,问你任意一种建设方法 Solution: 图里没有障碍,所以先把前k - 1个管道每个分2个长度,最后一个管 ...

  4. cf#514B. Forgery(暴力)

    B. Forgerytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputsta ...

  5. CF 987C Three displays DP或暴力 第十一题

    Three displays time limit per test 1 second memory limit per test 256 megabytes input standard input ...

  6. CF 702B Powers of Two(暴力)

    题目链接: 传送门 Devu and Partitioning of the Array time limit per test:3 second     memory limit per test: ...

  7. [ 9.12 ]CF每日一题系列—— 960B暴力数组

    Description: 给你两个数组,顺序一定,问你第一个数组连续的几个值等于下一个数组连续的几个值,然后寻找这个值得最大值,也就是满足就换 Solution: 用两个变量索引,判断即可 #incl ...

  8. CF 558 C. Amr and Chemistry 暴力+二进制

    链接:http://codeforces.com/problemset/problem/558/C C. Amr and Chemistry time limit per test 1 second ...

  9. CF 305A——Strange Addition——————【暴力加技巧】

    A. Strange Addition time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

随机推荐

  1. C#编程思想(持续更新)

    1.将约束的参数先用变量保存,一定不变的设为const,在使用时不直接填入数字而是使用这些变量,这样可以很大程度上方便后续参数的修改 2.字段先用属性封装后,所有的调用都使用属性而不是字段 3.要返回 ...

  2. UML图的使用

    UML(Unified Modeling Language)中文统一建模语言,是一种开放的方法,用于说明.可视化.构建和编写一个正在开发的.面向对象的.软件密集系统的制品的开放方法. 类之间的关系 在 ...

  3. MySQL-5.7数据库主从同步实战教程

    主从形式 MySQ主从复制原理(主库写入数据,从库读取数据) MySql常用命令: MySQL5.7设置密码 ') where user='root': MySQL5.6设置密码 ') WHERE U ...

  4. c# 线程锁 ,

    using System; using System.Collections.Generic; using System.Text; using System.Threading; namespace ...

  5. html页面设置<span>的高度和宽度

    <span>标签属于行内元素(inline),所以无法设置高度和宽度:如果需要改变其宽高,就需要将其转变为块体元素(block)或行内块体元素(inle-block): 1 span{di ...

  6. Jupyter 同时支持python2, python3

    从docker hub 下载了一个 tensorFlow 镜像,但是里面只支持python2.7 kernel, 不支持python3 kernel. 1. Notebook的右上角点new 只看到 ...

  7. luogu P2520 [HAOI2011]向量

    传送门 一堆人说数论只会gcd,我连gcd都不会,菜死算了qwq Orzyyb 这题欺负我数学不好qwq 首先可以发现实际上有如下操作:x或y±2a,x或y±2b,x+a y+b,x+b y+a(后面 ...

  8. Hbase思维导图之物理模型

  9. python - 获取win系统参数,发送/保存配置

    import wmi import json c = wmi.WMI () msg = {} # 系统信息:系统版本,主机名,系统安装时间,系统位数,串口ID,总内存大小 system = ['Cap ...

  10. 前端 - jquery方式 / iframe +form 方式 上传文件

    环境与上一章一样 jquery 方式上传文件: HTML代码 {#html代码开始#} <input type="file" id="img" > ...