NYOJ 664 Integer Division

Source: Internet
Author: User

Number division time limit: 1000 MS | memory limit: 65535 KB difficulty: 2

Description

Theorem:Remove the one-digit number of at least two positive integers, And then subtract 5 times of the single-digit number from the remaining number. When the only difference is a multiple of 17, the original number is also 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. Enter a positive integerNYour task is to determine whether it is a multiple of 17.

The input file contains up to 10 groups of test data, each of which occupies one row and contains only one positive integer n (1 <=n <= 10 ^ 100), indicating the positive integer to be judged. N = 0 indicates that the input is over. Your program should not process this line.
For each group 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
17171717171717171717171717171717171717171717171717180
Sample output
1
0
1
0
Simulate the division process!
AC code:
#include
    
     int main(){int i,sum;char str[105];while(scanf("%s",str)&&str[0]!='0'){sum=0;for(i=0;str[i]!='\0';i++){sum=sum*10+str[i]-'0';sum=sum%17;}printf("%s\n",sum?"0":"1");}return 0;}
    


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.