标签:
题意:
给出一个数字 , 往其末尾加上n个数字,每次添加的时候保证其 % k == 0
输出最终数字
题解:
只需要保证第一个数字合法, 然后往后面加上n-1个0
代码 :
#include<stdio.h>
#include<string.h>
int main()
{
int a, b, n;
char s1[200010];
while(scanf("%d %d %d", &a, &b, &n) != EOF)
{
memset(s1, ‘\0‘, sizeof(s1));
sprintf(s1, "%d", a);
int len = strlen(s1);
int c = a % b, flag = 0, d;
c *= 10;
c %= b;
d = (b - c) % b;
if(d >= 10) {flag = 1;}
else
{
s1[len ++] = (d + ‘0‘);
for(int i = 2; i <= n; i++)
{
s1[len ++] = ‘0‘;
}
}
if(flag) printf("-1\n");
else
printf("%s\n", s1);
}
}
标签:
原文地址:http://blog.csdn.net/q651111937/article/details/46550957