UVa 10551

  题目大意:关于大数的mod和进制转换,直接使用Java的BigInteger类,正在copy式学习中...

 1 import java.io.*;
 2 import java.util.*;
 3 import java.math.*;
 4 
 5 class Main
 6 {
 7     public static void main(String[] args)
 8     {
 9         Scanner sc = new Scanner(System.in);
10         while (true)
11         {
12             int base = sc.nextInt();
13             if (base == 0)  break;
14             String p_str = sc.next();
15             BigInteger p = new BigInteger(p_str, base);
16             String m_str = sc.next();
17             BigInteger m = new BigInteger(m_str, base);
18             System.out.println((p.mod(m)).toString(base));
19         }
20     }
21 }
View Code
原文地址:https://www.cnblogs.com/xiaobaibuhei/p/3322496.html