作者: | 来源:互联网 | 2023-09-18 17:08
web前端|html教程CodeforcesRound#277.5(Div.2)(C题)web前端-html教程C.GivenLengthandSumofDigitsquat
web前端|html教程
Codeforces Round #277.5 (Div. 2)(C题)
web前端-html教程
C. Given Length and Sum of Digits…
quaternion 源码,vscode插件介绍,ubuntu怎么在vi编辑文本,润乾 tomcat,wamp5 sqlite,js图形报表插件,前端框架模板兼容app,骷髅爬虫动画片,php excel 乱码,包年seo推广,门户网站源码带手机版,手机网页设计代码大全,杰奇小说换模板,zencart程序下载lzw
time limit per test
查询打印源码,ubuntu多网口,使用tomcat访问不了了,毛爬虫在哪,php转换数字函数,seo整站执行者seolzw
1 second
asp个人博客系统源码,wget vscode,ubuntu 结束进程,aspx tomcat,io和sqlite,云服务器和虚拟主机哪个好,ecshop 限时秒杀购买插件,前端浮窗框架,网络爬虫的定义,php需要培训,seo快速刷排名,国外优秀企业网站模板,网页条框颜色不变,卡盟模板,html模板页面详情页,人力资源管理系统 数据库,程序员 代码网站lzw
memory limit per test
256 megabytes
input
standard input
output
standard output
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes.
Input
The single line of the input contains a pair of integers m, s (1?≤?m?≤?100,?0?≤?s?≤?900) ? the length and the sum of the digits of the required numbers.
Output
In the output print the pair of the required non-negative integer numbers ? first the minimum possible number, then ? the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers “-1 -1” (without the quotes).
Sample test(s)
input
2 15
output
69 96
input
3 0
output
-1 -1
#include #include #include using namespace std;bool can(int m, int s){ if(s >= 0 && 9*m >= s) return true; else return false;}int main(){ int m,s; cin>>m>>s; if(!can(m,s)) { cout<<"-1"<<" "<<"-1"<= 10) { cout<<"-1"<<" "<<"-1"< 1) ) && can(m - i, sum - j)) { minn += char('0' + j); sum -= j; break; } } sum = s; for(int i = 1; i = 0; j--) {if(can(m - i, sum - j)) { maxn += char('0' + j); sum -= j; break; } } cout<