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.
Examples
input
Copy
3 2output
Copy
712
这题感觉好坑啊,很水的一道题,我却把自己给坑了,越想越复杂。
这题的大概意思就是说,你要找到一个数字,这个数字的长是n<=100,且这个数字能被t整除,因为感觉这个数字比较大,所以一时间没了思路,唉,其实很简单的啊,只要你输出n个t就行了啊,这个数字肯定可以被t整除啊。
这么简单的题都没有想出来,还是自己刷的题太少,自己太笨了吧!下面给出AC代码:
#include<stdio.h>
#include<string.h>
using namespace std;
int main()
{
int n,m;
scanf("%d %d",&n,&m);
if(n==1&&m==10) printf("-1");
else
{
if(m==10)
{
printf("1");
n--;
while(n--)
printf("0");
}
else
{
while(n--)
printf("%d",m);
}
}
return 0;
}