zoukankan      html  css  js  c++  java
  • HDU 5832 A water problem

    题目链接:

    http://acm.hdu.edu.cn/showproblem.php?pid=5832

    Problem Description
    Two planets named Haha and Xixi in the universe and they were created with the universe beginning.

    There is 73 days in Xixi a year and 137 days in Haha a year. 

    Now you know the days N after Big Bang, you need to answer whether it is the first day in a year about the two planets.
     
    Input
    There are several test cases(about 5 huge test cases).

    For each test, we have a line with an only integer N(0N), the length of N is up to 10000000.
     
    Output
    For the i-th test case, output Case #i: , then output "YES" or "NO" for the answer.
     
    Sample Input
    10001
    0
    333
     
    Sample Output
    Case #1: YES
    Case #2: YES
    Case #3: NO

     Hint:

    题意:

    就是给一个数n,让你看看是不是能够被73,137整除。

    题解:

    其实就是一道水题,十分水的题目,但是比赛的时候还是wa了,主要注意两点,一点是这个n是比较大的,所以要用的大数的除法,还有一点就是不能直接除以10001,自己就是因为这个一直在超时。

    代码:

    #include <cstdio>
    #include <cstring>
    #include <iostream>
    #include <algorithm>
    using namespace std;
    #define maxn 10000000+10
    #define met(a,b) memset(a,b,sizeof(a))
    char s[maxn];
    int main()
    {
        int k=1;
        while(scanf("%s",s)!=EOF)
        {
            printf("Case #%d: ",k++);
            int l=strlen(s);
            int  ans1=0,ans2=0;
            for(int i=0;i<l;i++)
            {
                ans1=(ans1*10+s[i]-'0')%73;
                ans2=(ans2*10+s[i]-'0')%137;
            }
            if(ans1==0&&ans2==0)
                printf("YES
    ");
            else
                printf("NO
    ");
        }
    }
    
  • 相关阅读:
    Flush输出表格内容
    [From Linux Toy] inxi– bash script to get system information
    .NET中Mocking框架的对比
    Python中的对象和动态性 [菜鸟的理解,高手莫入]
    《正见 佛陀的证悟》读书摘记 (1)
    Quote for tomorrow
    不抱怨就会死
    web deploy + windows server 2008 r2 64bit + iis 7.5
    bootsnipp
    [转载] A Beginner's Guide to HTTP Cache Headers
  • 原文地址:https://www.cnblogs.com/TAT1122/p/5777726.html
Copyright © 2011-2022 走看看