CF 277.5 C.Given Length and Sum of Digits.. 构造
- #include <cstdio>
- #include <cmath>
- #include <cstring>
- #include <ctime>
- #include <iostream>
- #include <algorithm>
- #include <set>
- #include <vector>
- #include <sstream>
- #include <queue>
- #include <typeinfo>
- #include <fstream>
- typedef long long ll;
- using namespace std;
- //freopen("D.in","r",stdin);
- //freopen("D.out","w",stdout);
- int a[];
- int main()
- {
- int m,s;
- cin>>m>>s;
- if(m==&&s==)
- {
- cout<<"0 0"<<endl;
- return ;
- }
- if(s==)
- {
- cout<<"-1 -1"<<endl;
- return ;
- }
- if(s>*m)
- {
- cout<<"-1 -1"<<endl;
- return ;
- }
- int t=s-;//精湛的-1 屌不屌?
- for(int i=;i<m;i++)
- {
- int r=min(t,);
- a[i]=r;
- t-=r;
- }
- a[m-]++;
- for(int i=m-;i>=;i--)
- cout<<a[i];
- cout<<" ";
- t=s;
- for(int i=;i<m;i++)
- {
- int r=min(,t);
- cout<<r;
- t-=r;
- }
- cout<<endl;
- return ;
- }
CF 277.5 C.Given Length and Sum of Digits.. 构造的更多相关文章
- codeforces#277.5 C. Given Length and Sum of Digits
C. Given Length and Sum of Digits... time limit per test 1 second memory limit per test 256 megabyte ...
- Codeforces Round #277.5 (Div. 2)C——Given Length and Sum of Digits...
C. Given Length and Sum of Digits... time limit per test 1 second memory limit per test 256 megabyte ...
- Codeforces Round #277.5 (Div. 2)-C. Given Length and Sum of Digits...
http://codeforces.com/problemset/problem/489/C C. Given Length and Sum of Digits... time limit per t ...
- CodeForces 489C Given Length and Sum of Digits... (贪心)
Given Length and Sum of Digits... 题目链接: http://acm.hust.edu.cn/vjudge/contest/121332#problem/F Descr ...
- CodeForces 489C Given Length and Sum of Digits... (dfs)
C. Given Length and Sum of Digits... time limit per test 1 second memory limit per test 256 megabyte ...
- B - Given Length and Sum of Digits... CodeForces - 489C (贪心)
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and th ...
- CodeForces 489C (贪心) Given Length and Sum of Digits...
题意: 找出m位且各个数位数字之和为s的最大和最小整数,不包括前导0(比如说003是非法的),但0是可以的. 分析: 这题是用贪心来做的,同样是m位数,前面的数字越大这个数就越大. 所以写一个can( ...
- Codeforces 489C Given Length and Sum of Digits...
m位长度,S为各位的和 利用贪心的思想逐位判断过去即可 详细的注释已经在代码里啦~ //#pragma comment(linker, "/STACK:16777216") //f ...
- codeforces 489C.Given Length and Sum of Digits... 解题报告
题目链接:http://codeforces.com/problemset/problem/489/C 题目意思:给出 m 和 s,需要构造最大和最小的数.满足长度都为 m,每一位的数字之和等于 s. ...
随机推荐
- u-boot移植随笔(7):u-boot启动流程简图【转】
转自:http://www.latelee.org/porting-uboot/u-boot-porting-bootstrap.html u-boot移植随笔:u-boot启动流程简图 画上面这张图 ...
- Linux内核跟踪之trace框架分析【转】
转自:http://blog.chinaunix.net/uid-20543183-id-1930846.html ---------------------------------------- ...
- Dapper实用教程
Dapper是什么? Dpper是一款.Net平台简单(Simple)的对象映射库,并且Dapper拥有着“微型ORM之王”的称号.就速度而言与手写ADO.NET SqlDateReader相同.OR ...
- [转载]Windows服务编写原理及探讨(3)
(三)对服务的深入讨论之下 现在我们还剩下一个函数可以在细节上讨论,那就是服务的CtrlHandler函数. 当调用RegisterServiceCtrlHandler函数时,SCM得到并保存这个回调 ...
- 十二、springboot之web开发之静态资源处理
springboot静态资源处理 Spring Boot 默认为我们提供了静态资源处理,使用 WebMvcAutoConfiguration 中的配置各种属性. 建议大家使用Spring Boot的默 ...
- 按需引入antd报错问题
1.使用create-react-app工具创建了一个项目 create-react-app antd-demo 2.安装babel-plugin-import npm install babel-p ...
- 洛谷P1841重要的城市
传送门啦 重要城市有三个性质如下: 1.重要城市能对其他两个不同城市的最短路径做出贡献 2.重要城市具有唯一性,如果两不同城市之间的最短路径有两种中间城市情况,那么这两个中间城市可以彼此代替,就都不能 ...
- Centos7.3安装和配置jre1.8
在正式环境里 我们可以不安装jdk ,仅仅安装Java运行环境 jre即可: 第一步:下载jre 我们去oracle官方下载下jre http://www.oracle.com/technetwork ...
- Shell学习笔记:#*、%*字符串掐头去尾方法
一.语法 在shell中可以通过#.%对字符串进行掐头去尾操作,使用方法如下: # 表示掐头 % 表示去尾 单个#或%表示最小匹配 双个$或%表示最大匹配 二.例子1 假设我们定义一个变量为: fi ...
- python2.7
python2.7支持win32.win64 下载地址:http://pan.baidu.com/s/1dE39eQ9 初学,附一个牛人的python教程地址:http://www.liaoxuefe ...