传送门:点击打开链接
题意:问
F(x,m)
代表一个全是由数字
x
组成的
思路:相当于
10m−19∗x%k≡c
是否成立
其实这个公式相当于
(10m−1)%9k9∗x%k=c%k
是否成立
这样的话,就能用快速幂做了
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <bitset>
#include <string>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <functional>
#define fuck(x) cout<<"["<<x<<"]";
#define FIN freopen("input.txt","r",stdin);
#define FOUT freopen("output.txt","w+",stdout);
//#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int MX = 2e4 + 5;
LL power(LL a, LL b, LL mod) {
LL ret = 1;
while(b) {
if(b & 1) ret = ret * a % mod;
a = a * a % mod;
b >>= 1;
}
return ret;
}
int main() {
//FIN;
int x, k, c; LL m;
int T, ansk = 0; scanf("%d", &T);
while(T--) {
scanf("%d%I64d%d%d", &x, &m, &k, &c);
printf("Case #%d:\n", ++ansk);
LL ans = (power(10, m, 9 * k) - 1 + 9 * k) % (9 * k);
if(ans * x / 9 == c) {
printf("Yes\n");
} else printf("No\n");
}
return 0;
}