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 ...
随机推荐
- Sql显示16进制
select cast(id as varbinary(4)) from tableTest
- C# "XXX.XmlSerializers”的程序集未能加载到..
解决办法,进入Debug目录, 1.如果X86平台 sgen xxx.exe /c:"/platform:x86" 2.不考虑平台 sgen xxx.exe 3.生成前事件命令行, ...
- Keil5创建GPIO
软件仿真如下图 Main.c内容 #include "stm32f10x.h" int main(void) { GPIO_InitTypeDef GPIO_InitStructu ...
- 对xml进行数据查询时发生NoClassDefFoundError,dom4j和jaxen
xml可扩展标记语言,标准通用标记语言的子集,是一种用于标记电子文件使其具有结构性的标记语言. 在web中,今天我本想测试一下用xml做为数据库存储用户信息,但是在查询用户信息的时候一直发生: jav ...
- ads出现村田电容电感无法仿真的问题解决(`BJT1' is an instance of an undefined model `BJTM1')
需要的控件是 murata include,该控件是跟随村田库一起倒入ADS中的
- solr 中文分词器IKAnalyzer和拼音分词器pinyin
solr分词过程: Solr Admin中,选择Analysis,在FieldType中,选择text_en 左边框输入 “冬天到了天气冷了小明不想上学去了”,点击右边的按钮,发现对每个字都进行分词. ...
- Linux ISO镜像挂载
挂载本地镜像? 镜像光盘的格式 iso9660 mount -t iso9660 -o,loop /data/centos.iso /iso 查看挂载磁盘 df -h cat /proc/mounts ...
- 配置mongo
Windows 平台安装 MongoDB MongoDB 下载 MongoDB 提供了可用于 32 位和 64 位系统的预编译二进制包,你可以从MongoDB官网下载安装,MongoDB 预编译二进制 ...
- 4-24日 collections模块 random模块 time模块 sys模块 os模块
1, collections模块 在内置数据类型(dict.list.set.tuple)的基础上,collections模块还提供了几个额外的数据类型:Counter.deque.defaultdi ...
- 深入理解 RPC
学习资料 https://juejin.im/book/5af56a3c518825426642e004