A. Olesya and Rodion
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
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.
Sample test(s)
input
3 2
output
712
构造题.
让构造任意一个n位数满足整除t
由于t是个位数==
所以很水.
-1的话只有n为1t为10的情况.
具体见代码...写得有点丑QAQ
1/*************************************************************************
2> File Name: code/cf/#324/A.cpp
3> Author: 111qqz
4> Email: rkz2013@126.com
5> Created Time: 2015年10月11日 星期日 23时32分46秒
6************************************************************************/
7
8#include<iostream>
9#include<iomanip>
10#include<cstdio>
11#include<algorithm>
12#include<cmath>
13#include<cstring>
14#include<string>
15#include<map>
16#include<set>
17#include<queue>
18#include<vector>
19#include<stack>
20#include<cctype>
21
22#define yn hez111qqz
23#define j1 cute111qqz
24#define ms(a,x) memset(a,x,sizeof(a))
25using namespace std;
26const int dx4[4]={1,0,0,-1};
27const int dy4[4]={0,-1,1,0};
28typedef long long LL;
29typedef double DB;
30const int inf = 0x3f3f3f3f;
31int n,t;
32int main()
33{
34#ifndef ONLINE_JUDGE
35// freopen("in.txt","r",stdin);
36#endif
37cin>>n>>t;
38if (n==1&&t;==10)
39{
40puts("-1");
41return 0;
42}
43if (n==1)
44{
45cout<<t<<endl;
46return 0;
47}
48if (t==10)
49{
50for ( int i = 1 ; i <=n-1 ; i++)
51cout<<1;
52cout<<0<<endl;
53return 0;
54}
55for ( int i = 1 ; i <= n ; i++)
56cout<<t;
57cout<<endl;
58
59
60#ifndef ONLINE_JUDGE
61fclose(stdin);
62#endif
63return 0;
64}