Multiple of 17
来源:互联网 发布:excel03查找重复数据 编辑:程序博客网 时间:2024/05/16 09:01
Multiple of 17Time Limit:1000MS Memory Limit:0KB 64bit IO Format:%lld & %llu
Description
Multiple of 17
Theorem: If you drop the last digitd of an integer n (n10), subtract 5d from the remaining integer, then the difference is a multiple of 17 if and only ifn is a multiple of 17.
For example, 34 is a multiple of 17, because 3-20=-17 is a multiple of 17; 201 is not a multiple of 17, because 20-5=15 is not a multiple of 17.
Given a positive integer n, your task is to determine whether it is a multiple of 17.
Input
There will be at most 10 test cases, each containing a single line with an integern (1n10100). The input terminates with n = 0, which should not be processed.
Output
For each case, print 1 if the corresponding integer is a multiple of 17, print 0 otherwise.
Sample Input
34201209876541317171717171717171717171717171717171717171717171717180
Sample Output
1010
Problemsetter: Rujia Liu, Special Thanks: Yiming Li
import java.math.BigInteger;import java.util.*;import java.math.*;public class Main {public static void main(String args[]) { Scanner sc = new Scanner(System.in); while(true) { BigInteger a = sc.nextBigInteger(); if(a.equals(BigInteger.ZERO)) { break; } BigInteger ans ; BigInteger b = a.mod(BigInteger.valueOf(10)); a = a.divide(BigInteger.valueOf(10)); a = a.subtract(b.multiply(BigInteger.valueOf(5))); a = a.abs(); ans = a.mod(BigInteger.valueOf(17)); if(ans.equals(BigInteger.ZERO)) { System.out.println(1); } else { System.out.println(0); } } }}
- Multiple of 17
- Multiple of 17
- uva 11879Multiple of 17
- UVa 11879 - Multiple of 17
- uva 11879 - Multiple of 17
- UVA 11879Multiple of 17
- toj 4607 Multiple of 17
- "multiple definition of" 错误
- multiple definition of...
- multiple definition of...
- 解决 multiple definition of
- extern: multiple definition of
- gcc: multiple definition of
- multiple definition of XXXX
- 解决 multiple definition of
- multiple definition of
- 116、multiple definition of
- gcc: multiple definition of
- LeetCode 78: Subsets
- 10G_liunx5.8_RAC install集群套件 之二
- vfs_read 用到
- cocos2d-html5学习笔记(七)--Action
- Android安全机制分析,及应用程序签名机制
- Multiple of 17
- 如何理解c和c ++的复杂类型声明
- 修改文件权限
- 头文件string与string.h的区别
- EditPlus 搭建 Lua 开发环境
- [cocos2d-x]HelloWorldDemo(Mac&Win7两个版本)
- C++拷贝构造函数详解
- Android DES加密的CBC和ECB加密解密模式
- 玩转Eclipse — 自动代码规范化