CF 489C 暴力处理
题意: 给你 数的长度 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 暴力处理的更多相关文章
- B. Lost Number【CF交互题 暴力】
B. Lost Number[CF交互题 暴力] This is an interactive problem. Remember to flush your output while communi ...
- 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 ...
- [ 9.11 ]CF每日一题系列—— 441C暴力模拟
Description: n * m 的地图,建设k个管道管道只能横竖走,且长度大于等于2,问你任意一种建设方法 Solution: 图里没有障碍,所以先把前k - 1个管道每个分2个长度,最后一个管 ...
- cf#514B. Forgery(暴力)
B. Forgerytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputsta ...
- CF 987C Three displays DP或暴力 第十一题
Three displays time limit per test 1 second memory limit per test 256 megabytes input standard input ...
- CF 702B Powers of Two(暴力)
题目链接: 传送门 Devu and Partitioning of the Array time limit per test:3 second memory limit per test: ...
- [ 9.12 ]CF每日一题系列—— 960B暴力数组
Description: 给你两个数组,顺序一定,问你第一个数组连续的几个值等于下一个数组连续的几个值,然后寻找这个值得最大值,也就是满足就换 Solution: 用两个变量索引,判断即可 #incl ...
- CF 558 C. Amr and Chemistry 暴力+二进制
链接:http://codeforces.com/problemset/problem/558/C C. Amr and Chemistry time limit per test 1 second ...
- CF 305A——Strange Addition——————【暴力加技巧】
A. Strange Addition time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
随机推荐
- 转载--关于hdfs
原文章链接 你肯定听过Hadoop,对就是那头奔跑的小象. 图片描述 Hadoop作为大数据时代代表性的解决方案被大家所熟知,它主要包含两部分内容: HDFS分布式文件存储 MapReduce分布式计 ...
- 如何在Mac上搭建自己的服务器——Nginx
1.安装Homebrew 打开终端,输入: ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/ ...
- SSH框架的搭建和测试(Spring + Struts2 + Hibernate)
SSH框架实现了视图.控制器.和模型的彻底分离,同时还实现了业务逻辑层与持久层的分离. Spring实现了MVC中的 Controller的功能,Struts实现Web视图的功能,Hibernate则 ...
- Windows下 OpenSSL DES加密配置
1.简介:OpenSSL项目是一个协作开发一个健壮的,商业级的,全功能的,并且开放源代码工具包,它实现了安全套接字层(SSL v2/v3)和传输层安全(TLS v1)协议以及全强大的通用加密库. 2. ...
- Oracle数据库XXE注入漏洞(CVE-2014-6577)分析
在这篇文中,我们将共同分析一下Oracle数据库的XXE注入漏洞(CVE-2014-6577),Oracle公司1月20日发布了针对该漏洞的相关补丁. 有关XXE的相关知识,可以查看安全脉搏站内的另一 ...
- C# 常用的工具方法
1.DateTime 转为Unix的long的时间戳 long orderTime = order.AddTime.ToUnixTimeStamp("Milliseconds"); ...
- Oracle DbHelper
wind8 系统选择项目时生成目标平台选择为X86 报错 “System.Exception”类型的未经处理的异常在 WindowsFormsApplication1.exe 中发生 其他信息: 尝试 ...
- matplotlib-2D绘图库-面向对象
个人理解:plt--画本 figure--产生画纸 子图 import numpy as np import matplotlib.pyplot as plt #解决能显示中文 plt.rcPa ...
- 2.4 if-else
if-else 想一想:在使用if的时候,它只能做到满足条件时要做的事情.那万一需要在不满足条件的时候,做某些事,该怎么办呢? 答:使用 if-else <1>if-else的使用格式 i ...
- [C++]2-3 倒三角形
/* 倒三角形(Triangle) 输入正整数n<=20,输出一个n层的倒等腰三角形. 0 ######### 9 = 2* n-1 1 ####### 7 = 2*(n-1)-1 2 #### ...