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.
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.
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.
3 2
712
思路:
一开始根本不知道题目说什么,一直都不会做。结果在临近比赛结束时,看到了多组答案,所以突然灵光一闪,是不是要n位且能被t整除的数,而且n是一个100位的,所以我就试一下。结果就是题目这个意思。英语差,不想说话了。(看懂题目就是水题一道)
AC代码:
#include<iostream> #include<algorithm> #include<cstring> #include<vector> #include<cstdio> #include<map> using namespace std; #define CRL(a) memset(a,0,sizeof(a)) typedef __int64 ll; #define T 1005 int main(){ /*freopen("input.txt","r",stdin);*/ int n,m,i,j,k,t; while(~scanf("%d%d",&n,&m)) { j=n-1;k=1; if(n==1&&m==10) printf("-1\n"); else if(m==10){ printf("1"); while(j--) { printf("0"); } printf("\n"); } else { while(n--){ printf("%d",m); } printf("\n"); } } return 0; }