zoukankan      html  css  js  c++  java
  • ZOJ 3622 Magic Number

    Magic Number

    Time Limit: 2 Seconds      Memory Limit: 32768 KB

    A positive number y is called magic number if for every positive integer x it satisfies that put y to the right of x, which will form a new integer z, z mod y = 0.

    Input

    The input has multiple cases, each case contains two positve integers m, n(1 <= m <= n <= 2^31-1), proceed to the end of file.

    Output

    For each case, output the total number of magic numbers between m and n(m, n inclusively).

    Sample Input

    1 1
    1 10
    

    Sample Output

    1
    4
    

    Author: QU, Zhe
    Contest: ZOJ Monthly, July 2012
    //下午月赛的第一题

    //开始少了2个数,郁闷了

    #include <iostream>
    #include <algorithm>
    #include <stdio.h>
    #include <string.h>
    #include <cmath>
    #include <stack>
    using namespace std;
    int dp[100];
    int nu;
    void set()
    {   dp[nu++]=1;
        int r[5]={1,2,4,5,8};
        int i,j;
        for(i=10;i<=1000000000;i*=10)
        {
            for(j=0;j<5;j++)
             if(i%r[j]==0)
              dp[nu++]=i/r[j];
        }
    }
    int main()
    {
        set();
        int i,k;
        sort(dp,dp+nu);

        dp[nu++]=1250000000;
        dp[nu++]=2000000000;
        int n,m;
        while(scanf("%d%d",&m,&n)!=EOF)
        {
            for(k=i=0;i<nu;i++)
              if(m<=dp[i]&&n>=dp[i])
                k++;
            printf("%d\n",k);
        }
        return 0;
    }

  • 相关阅读:
    Typora入门使用
    什么是Structed Streaming?
    Spark的join什么情况下可以避免shuffle?
    spark Executor启动过程分析
    在IDEA中使用Git
    Git和SVN的区别
    Flink on Yarn的两种模式
    如何查看执行计划
    SQL Server 堆表与栈表的对比(大表)
    SQL Server中CURD语句的锁流程分析
  • 原文地址:https://www.cnblogs.com/372465774y/p/2614313.html
Copyright © 2011-2022 走看看