Codeforces Round #277.5 (Div. 2)(C题)
来源:互联网 发布:听力复读软件 编辑:程序博客网 时间:2024/05/16 23:58
#include <iostream>#include <algorithm>#include <cstdio>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"<<endl; return 0; } if(m == 1) { if(s >= 10) { cout<<"-1"<<" "<<"-1"<<endl; } else cout<<s<<" "<<s<<endl; } else { if(s == 0) cout<<"-1"<<" "<<"-1"<<endl; else { string minn, maxn; int sum = s; for(int i = 1; i <= m; i++) for(int j = 0; j < 10; j++) { if((j > 0 || (j == 0 && i > 1) ) && can(m - i, sum - j)) { minn += char('0' + j); sum -= j; break; } } sum = s; for(int i = 1; i <= m; i++) for(int j = 9; j >= 0; j--) { if(can(m - i, sum - j)) { maxn += char('0' + j); sum -= j; break; } } cout<<minn<<" "<<maxn<<endl; } } return 0;}
0 0
- Codeforces Round #277.5 (Div. 2)(C题)
- Codeforces Round #277.5 (Div. 2)-C
- Codeforces Round #277.5 (Div. 2) C
- Codeforces Round #277.5 (Div. 2) C
- Codeforces Round 134 div 2 C题
- Codeforces Round #153 (Div. 2) C题
- Codeforces Round #158 (Div. 2) C题
- Codeforces Round #257 (Div. 2) C题
- Codeforces Round #404 (Div. 2) C题
- 【codeforces】Codeforces Round #370 (Div. 2) C
- Codeforces (441C) Round #252 (Div. 2) C题
- Codeforces Round #277.5 (Div. 2)E题
- Codeforces Round #277.5 (Div. 2)F题
- Codeforces Round #277.5 (Div. 2)
- Codeforces Round #277.5 (Div. 2)
- Codeforces Round #277.5 (Div. 2)
- Codeforces Round #277.5 (Div. 2)
- Codeforces Round #277.5 (Div. 2)
- suspend-resume(3)
- MySql MediumBlob
- C++单例模式
- Redis过期键
- jQuery html5Validate基于HTML5表单验证插件
- Codeforces Round #277.5 (Div. 2)(C题)
- Codeforces Round #277.5 (Div. 2)
- 关于销售订单高级定价的一点疑惑
- linux下更新python版本
- Android学习之客户端的开发(练习)
- static函数与普通函数
- SIGKDD国际会议简介(未完待续)
- android public.xml 用法
- Evolution 使用QQ邮箱