博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
B - Adding Digits CodeForces - 260A
阅读量:4136 次
发布时间:2019-05-25

本文共 1408 字,大约阅读时间需要 4 分钟。

Vasya has got two number: a and b. However, Vasya finds number a too short. So he decided to repeat the operation of lengthening number a n times.

One operation of lengthening a number means adding exactly one digit to the number (in the decimal notation) to the right provided that the resulting number is divisible by Vasya’s number b. If it is impossible to obtain the number which is divisible by b, then the lengthening operation cannot be performed.

Your task is to help Vasya and print the number he can get after applying the lengthening operation to number a n times.

Input

The first line contains three integers: a, b, n (1 ≤ a, b, n ≤ 105).

Output

In a single line print the integer without leading zeros, which Vasya can get when he applies the lengthening operations to number a n times. If no such number exists, then print number -1. If there are multiple possible answers, print any of them.

Examples

Input
5 4 5
Output
524848
Input
12 11 1
Output
121
Input
260 150 10
Output
-1

疯狂的补原来的训练题,这几次的训练题目都是树形dp,但是这道题不是哈。

其实挺水的一道题目,给你一个数n还有一个数m,在n后面加上k个数使之成为m的倍数,可以的话就任意输出,不可以的话就输出-1。只需要看看第二位可不可以就好了,可以整除的话就就把后面全部补成零,不可以就输出-1。
代码如下:
#include
#include
#include
using namespace std;

int n,m,k;

int main()
{
while(cin>>n>>m>>k)
{
int flag=1;
for(int i=0;i<=9;i++)
{
if((n*10+i)%m==0)
{
flag=0;
cout<<n<<i;
for(int i=1;i<k;i++) cout<<0;
cout<<endl;
break;
}
}
if(flag) cout<<"-1"<<endl;
}
}
努力加油a啊,(o)/~

转载地址:http://qzxvi.baihongyu.com/

你可能感兴趣的文章
C++学习路线
查看>>
私有构造函数
查看>>
组队总结
查看>>
TitledBorder 设置JPanel边框
查看>>
DBCP——开源组件 的使用
查看>>
抓包工具
查看>>
海量数据相似度计算之simhash和海明距离
查看>>
DeepLearning tutorial(5)CNN卷积神经网络应用于人脸识别(详细流程+代码实现)
查看>>
DeepLearning tutorial(6)易用的深度学习框架Keras简介
查看>>
DeepLearning tutorial(7)深度学习框架Keras的使用-进阶
查看>>
流形学习-高维数据的降维与可视化
查看>>
Python-OpenCV人脸检测(代码)
查看>>
python+opencv之视频人脸识别
查看>>
人脸识别(OpenCV+Python)
查看>>
6个强大的AngularJS扩展应用
查看>>
网站用户登录系统设计——jsGen实现版
查看>>
第三方SDK:讯飞语音听写
查看>>
第三方SDK:JPush SDK Eclipse
查看>>
第三方开源库:imageLoader的使用
查看>>
自定义控件:飞入飞出的效果
查看>>