Codeforces Round #324 (Div. 2) 584A. Olesya and Rodion

53 篇文章 0 订阅
44 篇文章 0 订阅
本文提供 Codeforces Round #324 (Div.2) A 题目“Olesya and Rodion”的解题思路及代码实现,探讨如何寻找一个由 n 位组成的数,该数同时满足大于0且能被 t 整除的条件。
摘要由CSDN通过智能技术生成


                             

               解题报告: Codeforces Round #324 (Div. 2)




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 ≤ 1002 ≤ 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整除的数,如果没有输出-1,n=1,t=10时为-1 。



#include 
     
     
      
      
#include 
      
      
       
       
#include 
       
       
        
        
using namespace std;
int main()
{
    int n,t,i;
    scanf("%d%d",&n,&t);
    if(n==1&&t==10) printf("-1\n");
    else
    {
        if(t==10)
        {
            printf("1");
            for(i=1; i
        
        
       
       
      
      
     
     





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值