HDU5832-CCPC Network race-high-precision redundancy

Source: Internet
Author: User
Title Address: http://acm.hdu.edu.cn/showproblem.php?pid=5832
The topic Two planets, one year 137 days, one year 73 days, give a day to ask is not at the same time is two planets in the first days. 0 represents the first day.
Thinking of solving problems
Because 137 and 73 are prime numbers, so the least common multiple is 10001, the problem is converted to a high-precision number of 10001 to take the remainder is equal to 0.
About high-precision redundancy. For example, 123 to 12, actually equals ((1%12*10+2)%12*10+3)%12=3, which is actually the process of simulating a division.
Code
#include <cstring>
#include <cstdio>
using namespace std;
#define MAXN 10005000
int A[MAXN];
int B[MAXN];
int Len;
Char STR[MAXN];
int main ()
{
    int i=1;
    while (scanf ("%s", str) ==1)
    {
        int tomod = 10001;
        int ans = 0;
        for (int j = 0; str[j]; j + +)
            ans = (ans * + (str[j]-' 0 '))% Tomod;
        if (ans)
            printf ("Case #%d:no\n", i++);
        else
            printf ("Case #%d:yes\n", i++);
    }
    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.