diff --git "a/khj20006/202503/06 BOJ P5 \353\266\204\354\210\230.md" "b/khj20006/202503/06 BOJ P5 \353\266\204\354\210\230.md" new file mode 100644 index 00000000..ec2d3d5d --- /dev/null +++ "b/khj20006/202503/06 BOJ P5 \353\266\204\354\210\230.md" @@ -0,0 +1,79 @@ +```java + +import java.util.*; +import java.io.*; +import java.math.BigInteger; + + +class Main { + + // IO field + static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + static StringTokenizer st; + + static void nextLine() throws Exception {st = new StringTokenizer(br.readLine());} + static int nextInt() {return Integer.parseInt(st.nextToken());} + static long nextLong() {return Long.parseLong(st.nextToken());} + static void bwEnd() throws Exception {bw.flush();bw.close();} + + // Additional field + + static long T, I, N; + static String A, B; + + public static void main(String[] args) throws Exception { + + T = Integer.parseInt(br.readLine()); + while(T-- > 0) { + + ready(); + solve(); + + } + + bwEnd(); + + } + + static void ready() throws Exception{ + + nextLine(); + A = st.nextToken(); + B = st.nextToken(); + + nextLine(); + I = nextLong(); + N = nextLong(); + + } + + static void solve() throws Exception{ + + BigInteger a = new BigInteger(A); + BigInteger b = new BigInteger(B); + a = a.mod(b); + + // a가 더 작으면 + BigInteger t = power(new BigInteger("10"), I-1, b); + a = a.multiply(t).mod(b); + for(int i=0;i>1, m).mod(m); + half = half.multiply(half).mod(m); + if(p%2 == 0) return half; + return half.multiply(x).mod(m); + } + +} + +```