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;}