日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

【CodeForces - 260A】Adding Digits (思维构造)

發(fā)布時間:2023/12/10 编程问答 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 【CodeForces - 260A】Adding Digits (思维构造) 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

題干:

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

解題報告:

? ? 先判斷第一個可以不可以,如果不可以輸出-1,如果可以就后面都輸出0。

AC代碼:

#include<cstdio> #include<iostream> #include<algorithm> #include<queue> #include<map> #include<vector> #include<set> #include<string> #include<cmath> #include<cstring> #define ll long long #define pb push_back #define pm make_pair #define fi first #define se second using namespace std; const int MAX = 2e5 + 5; ll a,b,n; ll cur; int main() {cin>>a>>b>>n;int flag = 0;for(int i = 0; i<=9; i++) {cur = a*10+i;if(cur%b == 0) {flag = 1;break;}}if(flag == 0) {puts("-1");return 0 ;}n--;printf("%lld",cur);for(int i = 1; i<=n; i++) putchar('0');return 0 ;}

總結:

? wjh大佬寫了dfs找到循環(huán)節(jié)然后再輸出的。

總結

以上是生活随笔為你收集整理的【CodeForces - 260A】Adding Digits (思维构造)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內容還不錯,歡迎將生活随笔推薦給好友。