1017 A除以B(JAVA)

本题要求计算 A/B,其中 A 是不超过 1000 位的正整数,B 是 1 位正整数。你需要输出商数 Q 和余数 R,使得 A=B×Q+R 成立。

输入格式:

输入在一行中依次给出 A 和 B,中间以 1 空格分隔。

输出格式:

在一行中依次输出 Q 和 R,中间以 1 空格分隔。

输入样例:

123456789050987654321 7

输出样例:

17636684150141093474 3

代码实现:

import java.io.*;
import java.math.BigInteger;
import java.util.Scanner;

/**
 * @author yx
 * @date 2022-07-14 1:33
 */
public class Main {
    /*
    考察大数
     */
    static PrintWriter out=new PrintWriter(System.out);
    static BufferedReader ins=new BufferedReader(new InputStreamReader(System.in));
    static StreamTokenizer in=new StreamTokenizer(ins);
    public static void main(String[] args) throws IOException {
        //使用IO进行快读
        //split返回的是一个String数组
        /*
        字符串最好不要用in来接收
         */
//        in.nextToken();String s1=in.sval;
//        BigInteger big1 = new BigInteger(s1);
//        in.nextToken();String s2=in.sval;
//        BigInteger big2 = new BigInteger(s2);
//        BigInteger[] ans=new BigInteger[2];可以不用数组
        String[] split=ins.readLine().split(" ");
        BigInteger big1=new BigInteger(split[0]);
        BigInteger big2=new BigInteger(split[1]);
        System.out.print(big1.divide(big2)+" ");
        System.out.print(big1.mod(big2));
    }
}

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小羊不会飞

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值