UVa 11879-multiple of 17

Source: Internet
Author: User

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

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.