Olesya and Rodion (思维)
Olesya loves numbers consisting of n digits, and Rodion only likes numbers that are divisible by t. Find some number that satisfies both of them.
Your task is: given the n and t print an integer strictly larger than zero consisting of n digits that is divisible by t. If such number doesn't exist, print - 1.
Input
The single line contains two numbers, n and t (1 ≤ n ≤ 100, 2 ≤ t ≤ 10) — the length of the number and the number it should be divisible by.
Output
Print one such positive number without leading zeroes, — the answer to the problem, or - 1, if such number doesn't exist. If there are multiple possible answers, you are allowed to print any of them.
Examples
Input
3 2
Output
712
思路:如果给定的n就输出n个t这样就整除为n个1,但是有一种特殊的n为1,t为10,是无法找到的,特判一下
代码:
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
int n,k;
cin>>n>>k;
if(n==1&&k==10) {
cout<<"-1"<<endl;
return 0;
}
if(k>=2&&k<=9) {
for(int t=0; t<n; t++) {
cout<<k;
}
} else {
for(int t=0; t<n; t++) {
if(t==0) {
cout<<"1";
} else {
cout<<"0";
}
}
}
return 0;
}
Olesya and Rodion (思维)的更多相关文章
- Codeforces Round #324 (Div. 2) A. Olesya and Rodion 水题
A. Olesya and Rodion Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/584/p ...
- Codeforce 584A - Olesya and Rodion
Olesya loves numbers consisting of n digits, and Rodion only likes numbers that are divisible by t. ...
- Codeforces Round #324 (Div. 2) Olesya and Rodion 构造
原题链接:http://codeforces.com/contest/584/problem/A 题意: 给你n和t,让你构造一个长度为n的数,并且被t整除 题解: 方法很多,可以乱构造.....不过 ...
- Codeforces Round #324 (Div. 2)解题报告
---恢复内容开始--- Codeforces Round #324 (Div. 2) Problem A 题目大意:给二个数n.t,求一个n位数能够被t整除,存在多组解时输出任意一组,不存在时输出“ ...
- Codeforces 584 - A/B/C/D/E - (Done)
链接:https://codeforces.com/contest/584 A - Olesya and Rodion - [水] 题解:注意到 $t$ 的范围是 $[2,10]$,对于位数小于 $2 ...
- Codeforces Round #324 (Div. 2) A
A. Olesya and Rodion time limit per test 1 second memory limit per test 256 megabytes input standard ...
- Codeforces Round #324 (Div. 2)
CF的rating设置改了..人太多了,决定开小号打,果然是明智的选择! 水 A - Olesya and Rodion #include <bits/stdc++.h> using na ...
- [C#][算法] 用菜鸟的思维学习算法 -- 马桶排序、冒泡排序和快速排序
用菜鸟的思维学习算法 -- 马桶排序.冒泡排序和快速排序 [博主]反骨仔 [来源]http://www.cnblogs.com/liqingwen/p/4994261.html 目录 马桶排序(令人 ...
- Photoshop、Illustrator思维导图笔记
半年前学习Photoshop时记得的思维导图笔记,可能不是很全,常用的基本都记下了.
随机推荐
- Oracle设置主键自增长
第一步:为表设置主键 第二步:新建序列 CREATE SEQUENCE SQ.SEQ_INCREASE START WITH 12 MAXVALUE 999 MINVALUE 0 INCREME ...
- css一div内文字居中
在说到这个问题的时候,也许有人会问CSS中不是有vertical-align属性来设置垂直居中的吗?即使是某些浏览器不支持我只需做少许的CSS Hack技术就可以啊!所以在这里我还要啰嗦两句,CSS中 ...
- 为什么要有http响应码
其实还是比较容易理解的.这就和你去小卖部买东西一样,老板,我想要一袋大米,那老板先得回答有还是没有,还是说我们这没有,去其它地方买去吧,得先给个说法,这个说法就是http相应码,有了http响应码之后 ...
- Paper: ImageNet Classification with Deep Convolutional Neural Network
本文介绍了Alex net 在imageNet Classification 中的惊人表现,获得了ImagaNet LSVRC2012第一的好成绩,开启了卷积神经网络在cv领域的广泛应用. 1.数据集 ...
- 8.python 系统批量运维管理器之pexpect模块
小插曲 前几节讲了paramiko模块,但是pexpect模块的功能几乎跟paramiko一样,先来分析一下: 1.各自介绍 pexpect是一个通过启动子程序,使用正则表达式对程序输出做出特定响应, ...
- HttpUploader7-授权码配置
1.1. 七牛云存储 配置方式: 1.配置授权码 2.配置云存储 3.配置空间名称 4.配置上传地址 1.2. 阿里云存储 配置方式: 1.填写授权码 2.配置云存储为阿里云 ...
- 升级Ubuntu 12.04下的gcc到4.7
我们知道C++11标准开始支持类内初始化(in-class initializer),Qt creator编译出现error,不支持这个特性,原因在于,Ubuntu12.04默认的是使用gcc4.6, ...
- Build fat static library (device + simulator) using Xcode and SDK 4+
155down votefavorite 185 It appears that we can - theoretically - build a single static library that ...
- Portal:Machine learning机器学习:门户
Machine learning Machine learning is a scientific discipline that explores the construction and stud ...
- XE StringGrid应用(G1属性触发G2)
unit UnitMain; interface uses System.SysUtils, System.Types, System.UITypes, System.Classes, System. ...