Http://hi.baidu.com/acmdearway/blog/item/e08db230563e3d13ebc4afa2.html
String ST = integer. tostring (Num, base); // convert num into base (base <= 35 ).
Int num = integer. parseint (St, base); // Use ST as the base and convert it to a 10-digit int (parseint has two parameters, and the first is the string to be converted, the second is to explain what the hexadecimal format is ).
Biginter M = new biginteger (St, base); // st is a string, and base is the base.
// Added by abilitytao
1. If you want to read a large number in binary format, you can use cin. nextbiginteger (2 );
Of course, you can also use other hexadecimal methods to read data;
2. If you want to convert a large number to a string in other hexadecimal forms, use cin. tostring (2); // convert it to a string in binary format.
View code
1 Import java. Math .*;
2 Import java. Io .*;
3 Import java. util .*;
4 Public Class Main {
5 Public Static Void Main (string ARGs [])
6 {
7 Scanner CIN = New Using (system. In );
8 Biginteger P, M, ans;
9 String STR;
10 Int B;
11 While (CIN. hasnext ())
12 {
13 B = cin. nextint ();
14 If (B = 0 ) Break ;
15 P = cin. nextbiginteger (B );
16 M = cin. nextbiginteger (B );
17 Ans = P. Mod (m );
18 STR = ans. tostring (B );
19 System. Out . Println (STR );
20 }
21 }
22 }