题意: 给你 数的长度 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. 032、学容器必须懂bridge网络(2019-02-19 周二)

    参考https://www.cnblogs.com/CloudMan6/p/7066851.html   docker安装时会创建一个名为 docker0 的linuxbridge.如果不指定 --n ...

  2. Linux 用top命令查看CPU和内存使用情况

    直接 top 回车 PID:进程的ID USER:进程所有者 PR:进程的优先级别,越小越优先被执行 NInice:值 VIRT:进程占用的虚拟内存 RES:进程占用的物理内存 SHR:进程使用的共享 ...

  3. SQL中间

    -- 查询门诊挂号退费的账单:有4条记录 select * from `thc_rcm`.`Cs_AccountBill` a where a.orderSource = 1 and a.orderT ...

  4. TCP时间获取程序

    一.服务器程序 #include <stdio.h> #include <stdlib.h> #include <time.h> #include <sys/ ...

  5. 关于Java 实现抽象类的抽象方法的特性的利用---面向切面

    今天看工作看代码突然有了以下设想: /** * Created by zq on 2017/5/25. * 抽象类 */ public abstract class AbstractC { publi ...

  6. tensorflow---文字识别

    读取数据的三种方法: 1. feeding : providing data when running each step : classifier.eval(feed_dict={input:my_ ...

  7. 使用PHP+MySql操作——实现微信投票功能

    1. 投票主页面: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://w ...

  8. Coursera, Deep Learning 5, Sequence Models, week2, Natural Language Processing & Word Embeddings

    Word embeding 给word 加feature,用来区分word 之间的不同,或者识别word之间的相似性. 用于学习 Embeding matrix E 的数据集非常大,比如 1B - 1 ...

  9. Kaldi的delta特征

    Delta特征是将mfcc特征(13维)经过差分得到的 它是做了一阶二阶的差分 提取的mfcc特征是13维的 然后通过delta就变成了39维 一阶差分: D(P(t))=P(t)-P(t-1) 二阶 ...

  10. java伪代码 大道至简第一章

    import.java.大道至简.*; //一·编程的精义 import.java.编程的精义.*; public class BIANCHENGDEJINGYI { if(愚公死了) 愚公的儿子,孙 ...