SWEA_D3_7193_승현이의 수학공부
in Category / Algorithm
7193. 승현이의 수학공부
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Solution {
static int T, N;
static long num;
static char X[];
static StringTokenizer st;
public static void main(String[] args) throws Exception {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
T = Integer.parseInt(in.readLine().trim());
for (int test_case = 1; test_case <= T; test_case++) {
st = new StringTokenizer(in.readLine());
N = Integer.parseInt(st.nextToken());
X = st.nextToken().toCharArray();
num = 0;
for (char c : X) {
num += c - '0';
}
System.out.println("#" + test_case + " " + num % (N - 1));
}
}
}