import java.math.BigInteger; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner cin = new Scanner(System.in); while (cin.hasNext()) { BigInteger b = cin.nextBigInteger(); if (b.compareTo(BigInteger.ZERO) == 0) break; String s1 = cin.next(), s2 = cin.next(); BigInteger p = BigInteger.ZERO, m = BigInteger.ZERO; for (int i = 0; i < s1.length(); i++) p = p.multiply(b).add(BigInteger.valueOf(s1.charAt(i) - '0')); for (int i = 0; i < s2.length(); i++) m = m.multiply(b).add(BigInteger.valueOf(s2.charAt(i) - '0')); BigInteger ans = p.mod(m); System.out.println(ans.toString(b.intValue())); } } }
Hello, I am a CS student from Taiwan.
I am learing English and Programming.
I'll save source code of some problems or small programs without comments in this blog.
I would recommend you not to read solution from others before you solved the problem.
(這邊專門存放沒有任何註解的小程式/OJ題目程式碼)
2012年12月17日
UVa 10551 - Basic Remains
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言