codeforces——584A——Olesya and Rodion

这篇博客介绍了如何解决codeforces上的584A问题,即找到一个由n位组成的数字,同时该数字能被t整除。题目要求输出一个大于0且不包含前导零的数,如果不存在则输出-1。内容包括问题描述、条件限制及可能的答案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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.

Examples
Input
3 2
Output
712

输入n,m,n为位数,m为所输出数可以整除的,没有可以输出的数,输出-1

水题

#include <iostream>
#include<cstring>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<set>
using namespace std;
int main()
{
    int n,m;
    while(cin>>n>>m!=NULL)
    {
        if(n==1&&m==10)
        {
            cout<<"-1"<<endl;
            continue;
        }
        cout<<m;
        m==10?n=n-2:n--;
        while(n--)
            cout<<'0';
        cout<<endl;
    }
    return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值