2013
11-11

# Basic remains

Given a base b and two non-negative base b integers p and m, compute p mod m and print the result as a base b integer. p mod m is defined as the smallest non-negative integer k such that p = a*m + k for some integer a.

Input consists of a number of cases. Each case is represented by a line containing three unsigned integers. The first, b, is a decimal number between 2 and 10. The second, p, contains up to 1000 digits between 0 and b-1. The third, m, contains up to 9 digits between 0 and b-1. The last case is followed by a line containing 0.

For each test case, print a line giving p mod m as a base-b integer.

2 1100 101
10 123456789123456789123456789 1000
0


10
789

import java.io.BufferedInputStream;
import java.math.BigInteger;
import java.util.Scanner;
public class Main {

public static void main(String[] args) {
Scanner scan = new Scanner(new BufferedInputStream(System.in));
while (scan.hasNext()) {
int b = scan.nextInt();
if (b == 0) {
break;
}
BigInteger p = scan.nextBigInteger(b);
BigInteger m = scan.nextBigInteger(b);
System.out.println(p.mod(m).toString(b));
}
}
}

1. Gucci New Fall Arrivals

This is really nice to know. I hope it will be successful in the future. Good job on this and keep up the good work.

2. 站长好。我是一个准备创业的互联网小白,我们打算做一个有关国*际*游*学的平台。手上也有了一些境外资源。现阶段的团队现在没有cto.原意出让一些管理股寻找一个靠谱的技术专家做合伙人, 不知道是不是能得到您的帮助。发个帖子或者其他方式。期待您的回应。可以加我微信tianxielemon聊聊。