Ultraviolet A 11879-multiple of 17

Source: Internet
Author: User

Question: calculate whether a number is a multiple of 17.

Description: String, large number. A simple question, which can be determined directly.

Set n = 10a + D; (0 ≤ d ≤ 9) then

A-5d = 51a-5N. If n is divisible by 17, this number must also be divisible by 17.

Note: The question gives a conclusion, which is not required. You can directly % 17 to determine the remainder.

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

Ultraviolet A 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.