↓ Skip to main content
  1. Posts/

codeforces #324 div 2 A. Olesya and Rodion

·377 words·1 min
Note: This article is available in Chinese only. 本文暂无英文版本。 View original

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

代码实现
 1/*************************************************************************
 2> File Name: code/cf/#324/A.cpp
 3> Author: 111qqz
 4> Email: rkz2013@126.com
 5> Created Time: 2015年10月11日 星期日 23时32分46秒
 6************************************************************************/
 7
 8#include<iostream>
 9#include<iomanip>
10#include<cstdio>
11#include<algorithm>
12#include<cmath>
13#include<cstring>
14#include<string>
15#include<map>
16#include<set>
17#include<queue>
18#include<vector>
19#include<stack>
20#include<cctype>
21
22#define yn hez111qqz
23#define j1 cute111qqz
24#define ms(a,x) memset(a,x,sizeof(a))
25using namespace std;
26const int dx4[4]={1,0,0,-1};
27const int dy4[4]={0,-1,1,0};
28typedef long long LL;
29typedef double DB;
30const int inf = 0x3f3f3f3f;
31int n,t;
32int main()
33{
34#ifndef  ONLINE_JUDGE
35//  freopen("in.txt","r",stdin);
36#endif
37cin>>n>>t;
38if (n==1&&t==10)
39{
40puts("-1");
41return 0;
42}
43if (n==1)
44{
45cout<<t<<endl;
46return 0;
47}
48if (t==10)
49{
50for ( int i = 1 ; i <=n-1 ; i++)
51cout<<1;
52cout<<0<<endl;
53return 0;
54}
55for ( int i = 1  ; i <= n ; i++)
56cout<<t;
57cout<<endl;
58
59
60#ifndef ONLINE_JUDGE
61fclose(stdin);
62#endif
63return 0;
64}

Related

[转自codeforces] How to come up with the solutions: techniques

·901 words·2 mins
As I work with students I often face the situation when if a problem doesn’t seem clear to a student at the first sight, it makes them unable to solve it. Indeed, you always hear about specific methods and techniques. But you don’t hear about how to think in order to apply them. In this note I’ll try to sum up my experience of solving programming contest problems. However, some pieces of advice will also be applicable for olympiads in mathematics and your first steps in academic research.

cf 556C Case of Matryoshkas

·377 words·1 min
http://codeforces.com/contest/556/problem/C 果然一晚上不睡觉会导致读错题么… 需要注意的是 如果有一个是 1 2 4 6 那么 1,2是不必拆开的….