import java.util.Scanner;
import java.math.BigInteger;
class Main {
public static void main(String[] args){
Scanner in=new Scanner(System.in);
while(true){
int b;
BigInteger p,m;
b=in.nextInt();
if(b==0)
return;
p=new BigInteger(in.next(),b);
m=new BigInteger(in.next(),b);
System.out.println((p.mod(m)).toString(b));
}
}
}
import java.math.BigInteger;
class Main {
public static void main(String[] args){
Scanner in=new Scanner(System.in);
while(true){
int b;
BigInteger p,m;
b=in.nextInt();
if(b==0)
return;
p=new BigInteger(in.next(),b);
m=new BigInteger(in.next(),b);
System.out.println((p.mod(m)).toString(b));
}
}
}
Comments
Post a Comment