Title: Calculates a number that is not 17 times times the number.
Description: string, lid plate.
Simple question, direct inference can be.
Set n = 10a + D; (0≤d≤9)
A-5D = 51a-5n, assuming that n is divisible by 17, the number must also be divisible by 17.
Description: The topic gave a conclusion, do not need to use, direct%17 infer the remainder can be.
#include <iostream> #include <cstdlib> #include <cstring> #include <cstdio>using namespace std; Char str[104];int val[104];int Main () {while (~SCANF ("%s", str)) {if (strlen (str) = = 1 && str[0] = = ' 0 ') break;i NT len = strlen (str), for (int i = 0; i < len; + + i) val[i] = str[i]-' 0 '; Val[len] = 0;for (int i = 0; i < Len; + +) i) val[i+1] + = val[i]%17*10; if (Val[len]) printf ("0\n"), Else printf ("1\n");} return 0;}
Copyright notice: This article blog original articles, blogs, without consent, may not be reproduced.
UVa 11879-multiple of 17