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