王品


私信TA

用户名:wangpin

访问量:18673

签 名:

等  级
排  名 493
经  验 4473
参赛次数 1
文章发表 41
年  龄 21
在职情况 学生
学  校 安徽师范大学皖江学院
专  业 软件工程

  自我简介:

参考代码:

import java.math.BigInteger;

import java.util.*;


public class Main {

    

    public static void main(String[] args) {

        Scanner sc=new Scanner(System.in);

        final BigInteger m17=BigInteger.valueOf(17);


        while(true)

        {

            String str=sc.nextLine();


            if(str.equals("0"))  //不能用if(str=="0")!!!!!!

                break;


            String firstStr=str.substring(0,str.length()-1);  //将字符串转换为大数

            String endStr=str.substring(str.length()-1);

            BigInteger a=new BigInteger(firstStr);


            int b= 5*Integer.parseInt(endStr);


            BigInteger b5=BigInteger.valueOf(b);

            BigInteger ab=a.subtract(b5);          //在对大数进行处理

            BigInteger eq=ab.mod(m17);

            System.out.println(eq==BigInteger.ZERO?1:0);

         }

    }

}


 

0.0分

0 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换

万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区