https://www.acwing.com/problem/content/description/4592/
import java.io.*;
import java.util.*;
class Main {
static int n;
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String[] s = br.readLine().split(" ");
n = Integer.parseInt(s[0]);
for (int i = 1; i <= n; i ++) {
s = br.readLine().split(" ");
String a = s[0];
long b = Long.parseLong(s[1]);
if (a.charAt(0) == '-') a = a.substring(1, a.length());
if (check(a, b)) {
System.out.println("Case " + i + ": divisible");
}
else System.out.println("Case " + i + ": not divisible");
}
}
/**
* ~~~不对
* 取模运算的加法规则
* (n + m) % p == (n % p + m % p) % p
* 在这个例子中就是:n = 7678123668327637674887634, m = 101
* 7678123668327637674887634 % 101 == (70000000... + 678123668327637674887634) % 101 ==
* 依次类推,
* ~~~
*
* 这里是模拟手算的过程
*/
private static boolean check(String a, long b) {
// System.out.println("a[0] = " + a.charAt(0));
long r = 0; // 余数
for (int i = 0; i < a.length(); i ++) {
r = r * 10 + a.charAt(i) - '0';
r %= b;
}
if (r == 0) return true;
return false;
}
}