#include <bits/stdc++.h>using namespace std;typedef long long ll;ll pow_mod(ll a, ll n, ll mod) { ll res = 1; while (n) { if (n & 1) res = res * a % mod; a = a * a % mod; n >>= 1; } return res;}ll dfs(ll x, ll n, ll mod) { if (n == 1) return x; ll mid = n / 2, res; ll tmp = dfs(x, mid, mod); if (n & 1) res = (tmp * 10 + x) % mod * pow_mod(10, mid, mod) % mod; else res = (tmp * pow_mod(10, mid, mod)) % mod; return (res + tmp) % mod;}int main() { int T, cs = 0; scanf("%d", &T); while (T--) { ll x, m, k, c; scanf("%I64d%I64d%I64d%I64d", &x, &m, &k, &c); PRintf("Case #%d:/n", ++cs); if (dfs(x, m, k) == c) puts("Yes"); else puts("No"); } return 0;}
新闻热点
疑难解答