modulo.java 497 B

12345678910111213141516
  1. import flanagan.io.KeyboardInput;
  2. import java.math.BigInteger;
  3. public class modulo {
  4. public static void main(String arg[]) {
  5. KeyboardInput kb = new KeyboardInput();
  6. BigInteger a = kb.readBigInteger("a =", 1);
  7. int b = kb.readInt("b =", 1);
  8. BigInteger r = a.mod(BigInteger.valueOf(b));
  9. BigInteger k = a.subtract(r).divide(BigInteger.valueOf(b));
  10. System.out.println("a = k * b + r");
  11. System.out.printf("k = %d, r = %d\n", k, r);
  12. }
  13. }