您的位置:首页 > 其它

codeforces #324 div 2 A. Olesya and Rodion

2015-10-11 23:53 239 查看
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

/*************************************************************************
> File Name: code/cf/#324/A.cpp
> Author: 111qqz
> Email: rkz2013@126.com
> Created Time: 2015年10月11日 星期日 23时32分46秒
************************************************************************/

#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<vector>
#include<stack>
#include<cctype>

#define yn hez111qqz
#define j1 cute111qqz
#define ms(a,x) memset(a,x,sizeof(a))
using namespace std;
const int dx4[4]={1,0,0,-1};
const int dy4[4]={0,-1,1,0};
typedef long long LL;
typedef double DB;
const int inf = 0x3f3f3f3f;
int n,t;
int main()
{
#ifndef  ONLINE_JUDGE
//  freopen("in.txt","r",stdin);
#endif
cin>>n>>t;
if (n==1&&t==10)
{
puts("-1");
return 0;
}
if (n==1)
{
cout<<t<<endl;
return 0;
}
if (t==10)
{
for ( int i = 1 ; i <=n-1 ; i++)
cout<<1;
cout<<0<<endl;
return 0;
}
for ( int i = 1  ; i <= n ; i++)
cout<<t;
cout<<endl;

#ifndef ONLINE_JUDGE
fclose(stdin);
#endif
return 0;
}


View Code
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: