您的位置:首页 > 其它

Olesya and Rodion(模拟)

2015-10-07 21:13 260 查看
A. Olesya and Rodiontime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputOlesya 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 printan integer strictly larger than zero consisting of n digits that is divisible by t.If such number doesn't exist, print  - 1.InputThe 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.OutputPrint one such positive number without leading zeroes, — the answer to the problem, or  - 1, if such number doesn't exist. If there are multiplepossible answers, you are allowed to print any of them.Sample test(s)input
3 2
output
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 1005int 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;}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  codeforces