The sixth session of Hunan Province Citic Software Education Cup??? The third question of the Student Program design contest is divisible by the number

Source: Internet
Author: User

http://www.baidu.com/


For each set of test data, the output line indicates whether the corresponding n is a multiple of 17. 1 indicates yes, 0 indicates no.


Sample Input


34

201

2098765413

1717171717171717171717171717171717171717171717171718

0


Sample Output


1

0

1

0


Problem Source


The sixth Hunan Collegiate programming Contest




Topic Connection: http://acm.hunnu.edu.cn/online/?action=problem&type=show&id=10932


Analysis: Simple large number of operations, according to the habit I like to do with Java

Source code:

Import Java.math.biginteger;import java.util.scanner;//The third topic of the sixth session of the ACM Program Design Competition in Hunan Province public class main {public static void main ( String[] args) {Scanner Scanner = new Scanner (system.in), while (Scanner.hasnext ()) {String str = scanner.next (); if (St R.equals (0)) {//careless place written Endwith led to WA six times yes, injury can not afford break;} int len = Str.length (); String aStr = str.substring (0, len-1); String bStr = str.substring (len-1); BigInteger num = new BigInteger (str);//The original number BigInteger a = new BigInteger (ASTR); BigInteger B = new BigInteger (BSTR); BigInteger n = biginteger.valueof (5); BigInteger temp = b.multiply (n);//?? Number of digits multiplied by 5 times times//System.out.println (temp); BigInteger r = a.subtract (temp);//Use the original remaining number minus 5* single digit/SYSTEM.OUT.PRINTLN (R); R = R.abs ();//Convert to absolute value//SYSTEM.OUT.PRINTLN (R); BigInteger m = biginteger.valueof (17); System.out.println (m); System.out.println (R.mod (m)); if (R.mod (m). CompareTo (biginteger.valueof (0)) = = 0 && num.mod (m). CompareTo (biginteger.valueof (0)) = = 0) { SYSTEM.OUT.PRINTLN (1); } else {SysTEM.OUT.PRINTLN (0); } } }}





The sixth session of Hunan Province Citic Software Education Cup??? The third question of the Student Program design contest is divisible by the number

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.