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

  • 相关阅读:
    JSON
    类的操作
    轮播图
    定时器的应用
    延时调用
    定时器
    跳表的java实现,转载自网络,仅供自己学习使用
    java实现判断两个二叉树是否相同
    开发小白工作过程中的一些经验记录,仅供自己参看查阅,转载请注明出处
    安卓基础入门二,转载自网络
  • 原文地址:https://www.cnblogs.com/372465774y/p/2614313.html
Copyright © 2011-2022 走看看