code1083,Codeforces Round #158 (Div. 2) A - Adding Digits

 2023-10-08 阅读 23 评论 0

摘要:題目:?http://codeforces.com/contest/260/problem/A 思路:a%b==0 => a*10^n%b==0 這題一開始忽略了一句話??If there are multiple possible answers, print any of them. code1083,想了半天覺得答案不只一種啊 然后看到n的范圍就知道

題目:?http://codeforces.com/contest/260/problem/A

思路:a%b==0 => a*10^n%b==0

這題一開始忽略了一句話??If there are multiple possible answers, print any of them.

code1083,想了半天覺得答案不只一種啊

然后看到n的范圍就知道這題不可能一位位算

#include <iostream>
#include <cstdlib>
using namespace std;int a,b,n;
int main()
{cin >> a>>b>>n;a*=10;int flag=0;for(int i=0;i<10;i++){if(a%b==0) {flag=1;    break;}a++;}if(flag){cout << a;for(int i=0;i<n-1;i++){cout<<"0";}cout << endl;}else{cout << "-1"<<endl;}
return 0;
}

?

轉載于:https://www.cnblogs.com/danielqiu/archive/2013/01/16/2863078.html

版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。

原文链接:https://hbdhgg.com/4/129976.html

发表评论:

本站为非赢利网站,部分文章来源或改编自互联网及其他公众平台,主要目的在于分享信息,版权归原作者所有,内容仅供读者参考,如有侵权请联系我们删除!

Copyright © 2022 匯編語言學習筆記 Inc. 保留所有权利。

底部版权信息