kuangbin 数学训练一 Integer Divisibility
题目链接:传送门#include<iostream>#include<cstring>#include<cstdio>#include<algorithm>#define ll long longusing namespace std;const int N = 200010;ll t, n, m, k, num, ans = 1;int main(
·
题目链接:
传送门
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#define ll long long
using namespace std;
const int N = 200010;
ll t, n, m, k, num, ans = 1;
int main() {
scanf("%lld", &t);
while(t--) {
ans = 1;
scanf("%lld%lld", &n, &m);
num = m;
//不断拼接
while(num % n != 0) num = (num * 10 + m) % n, ans++;
printf("Case %lld: %lld\n", ++k, ans);
}
}
这道简单模拟一下就好了,一直把数字拼在某个数字后面,直到拼出出一个能被目标数字整除的数即可,期间记录一下拼接次数加上本身1个即为答案。
更多推荐
所有评论(0)