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. ...
随机推荐
- 曹冲称象小游戏pygame实现
#!/usr/bin/env python # -*- coding: UTF-8 -*- import pygame from pygame.locals import * from sys imp ...
- idea添加jdbc包
IDEA版本:IDEA 14 这里我使用的第三方jar包是数据库的JDBC jar包导出案例. 1.创建一个Module,名称为dataBase,在里面我们先创建一个folder用来包含所需要的jar ...
- RNN BPTT
双向LSTM
- wiki confluence安装
注意:安装前请先确认内存 至少2G 1.上传 atlassian-confluence-5.9.3-x64.bin 文件,修改权限 chmod 777 atlassian-confluence-5.9 ...
- 洛谷P2017晕牛
传送门啦 这个题没有想象中复杂. 我们先有向边建立,因为我们无法改变有向边的方向. 建立完之后跑一边拓扑排序,我们按拓扑序小的指向大的就好了. 解释: 我们知道如果一个点在另一个点顺序的后面的话,如果 ...
- pom.xml一个简单配置
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/20 ...
- python对象学习
python对象的介绍 python使用对象模型来存储数据,构造任何类型的值都是一个对象,尽管python被当成面向对象的编程语言,但是完全编写不使用任何类和实例的脚本.所有的python对象都拥有三 ...
- Linux下的堆伪造漏洞利用技术(new unlink)
感觉markdown的文件格式看起来更清晰一些就写成附加的形式了.Download 更正:这种利用方式不叫House of Mind,是我搞混了.
- CentOS7.5之Sqoop1.4.7的安装使用
一 Sqoop简介 Apache Sqoop(TM) 于 2012 年 3 月孵化出来,现在是一个顶级的 Apache 项目.是一种旨在有效地在 Apache Hadoop 和诸如关系数据库等结构化数 ...
- day2编写购物商城
作业:购物商城 商品展示,价格 买,加入购物车 付款,钱不够 流程图如下: 代码共有4个文件,如下: 用户文件: alex geng zhang lou zeng 商品文件: 小米3 比亚迪宋 格力变 ...