import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
public class Main {
public static void main(String[] args) throws IOException {
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
StringBuilder sb = new StringBuilder("");
String m="";
while(true){
m=br.readLine();
if("0".equals(m))
break;
String[] str=m.split(" ");
int base=Integer.parseInt(str[0]);
BigInteger bg1=new BigInteger(str[1],base);
BigInteger bg2=new BigInteger(str[2],base);
BigInteger rs=bg1.mod(bg2);
sb.append(rs.toString(base)).append("\n");
}
System.out.print(sb);
}
}
No comments:
Post a Comment