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 2output
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 Round #197 (Div. 2)
- Codeforces Round #198 (Div. 1)
- Codeforces 405E Codeforces Round #238 (Div. 2)E
- Codeforces 407C Codeforces Round #239 (Div. 1)C
- CodeForces 449A - Jzzhu and Chocolate
- CodeForces 449 B. Jzzhu and Cities
- Codeforces Round #265 (Div. 2)
- Codeforces #310 div2 C. Case of Matryoshkas
- 状态压缩DP codeforces 244 Problem C. The Brand New Function 和 codeforces 165 E. Compatible Numbers
- codeforces 16 Problem E fish
- Codeforces round #247 for Div. 2
- Codeforces Round #246 (Div. 2)
- Codeforces #264(div 2)D.Gargari and Permutations
- Codeforces Round #236 (Div. 2)------A,B
- codeforces 257 div2 B
- Codeforces Gym100571A Cursed Query
- Codeforces Gym100342E Minima
- Codeforces Gym100342J Triatrip
- Codeforces Gym100286B Blind Walk (dfs)
- Codeforces Gym100342J Triatrip