UVa 10929 You can say 11 (number theory)

Source: Internet
Author: User

10929-you can say 11

Time limit:3.000 seconds

Http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem &problem=1870

Introduction to the problem

Your job is, given a positive number N, determine if it is a multiple of eleven.

Description of the input

The input is a file such so each line contains a positive number. A line containing the "number 0 is the" end of the input. The given numbers can contain up to 1000 digits.

Description of the output

The output of the program shall indicate, for each input number, if it is a multiple of eleven or.

Sample Input:

112233

30800

2937

323455693

5038297

112234

0

Sample Output

112233 is a multiple of 11.

30800 is a multiple of 11.

2937 is a multiple of 11.

323455693 is a multiple of 11.

5038297 is a multiple of 11.

112234 is not a multiple of 11.

Method 1: Start mod 11 directly from single-digit digits.

/*0.026s*/
  
#include <cstdio>
#include <cstring>
  
char s[1005];
  
int main (void)
{
    int remainder;
    while (gets (s), strcmp (S, "0"))
    {
        remainder = 0;
        for (int i = 0; s[i]; i++)
            remainder = (remainder * + (s[i) &))%;
        if (remainder) printf ("%s is not a multiple of 11.\n", s);
        else printf ("%s is a multiple of 11.\n", s);
    }
    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.