zoukankan      html  css  js  c++  java
  • zoj 3622 Magic Number (构造?)

    A - Magic Number
    Time Limit:2000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu
    Submit Status

    Description

    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 zz mod y = 0.

    Input

    The input has multiple cases, each case contains two positve integers mn(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(mn inclusively).

    Sample Input

    1 1
    1 10
    

    Sample Output

    1
    4

    浙大某次月赛的题。
    其实是水题。。然而。。。

    每考虑清楚就写== 太傻逼了==
    这样的数其实是很少的...
    1 2 5
    10 25 50 1000
    100 125 200 250 1000 ...
    (以开始丢掉了25 125这一组以及对应后面的)
    为什么知道有这些呢...
    其实从小的看
    1/1 =1
    1/2 = 0.5
    1/4 =0.25
    1/5 =0.2
    1/8=0.125
    1/16 = 0.0625
    这些都是可以可以初尽的,只要足够大,就可以满足条件。
    而1/3 1/6 1/9 1/11之类的就算了...
    但是为什么只到125呢?
    因为题目中是是加到任意整数右边 最小的是1
    那么(这个数的位数+1)×10 必须要能满足整除这个数...
    而625或者6250以及以后不满足这个条件
    以后的更不满足。
    说白了就是1除以某个数必须能整除而且小数点后第一位不为0
     1 /*************************************************************************
     2     > File Name: code/zoj/r3622.cpp
     3     > Author: 111qqz
     4     > Email: rkz2013@126.com 
     5     > Created Time: 2015年10月19日 星期一 12时41分37秒
     6  ************************************************************************/
     7 
     8 #include<iostream>
     9 #include<iomanip>
    10 #include<cstdio>
    11 #include<algorithm>
    12 #include<cmath>
    13 #include<cstring>
    14 #include<string>
    15 #include<map>
    16 #include<set>
    17 #include<queue>
    18 #include<vector>
    19 #include<stack>
    20 #include<cctype>
    21                  
    22 #define yn hez111qqz
    23 #define j1 cute111qqz
    24 #define ms(a,x) memset(a,x,sizeof(a))
    25 using namespace std;
    26 const int dx4[4]={1,0,0,-1};
    27 const int dy4[4]={0,-1,1,0};
    28 typedef long long LL;
    29 typedef double DB;
    30 const int inf = 0x3f3f3f3f;
    31 LL m,n,s[10];
    32 int main()
    33 {
    34   #ifndef  ONLINE_JUDGE 
    35    freopen("in.txt","r",stdin);
    36   #endif
    37 
    38 
    39    int ans;
    40    double p = 1;
    41  //  for ( int i = 1 ; i <= 20 ; i ++)
    42  //   {
    43 //    cout<<(1.0/p)<<endl;
    44 //    p = p * 2;
    45 //    }
    46    
    47 
    48    while (scanf("%lld %lld",&m,&n)!=EOF)
    49     {
    50     ans =  0;
    51     int cnt  = 0;
    52     s[1] = 1;
    53     s[2] = 125;
    54     s[3] = 2;
    55     s[4] = 25;
    56     s[5] = 5; 
    57     while (1)
    58     {
    59         bool ok;
    60         for ( int i = 1 ; i <= 5 ; i++)
    61         {
    62         cnt++;
    63         if (s[i]>=m&&s[i]<=n)
    64         {
    65             ans++;
    66 //            cout<<"s[i]:"<<s[i]<<endl;
    67         }
    68     //    cout<<"cnt:"<<cnt<<endl;
    69 
    70         s[i] = s[i] * 10;
    71         if (cnt>=100) break;
    72         }
    73         if (cnt>=100) break;
    74     }
    75     printf("%d
    ",ans);
    76     
    77 
    78 
    79     }
    80   
    81    
    82  #ifndef ONLINE_JUDGE  
    83   fclose(stdin);
    84   #endif
    85     return 0;
    86 }
    View Code
  • 相关阅读:
    122. Best Time to Buy and Sell Stock II
    121. Best Time to Buy and Sell Stock
    72. Edit Distance
    583. Delete Operation for Two Strings
    582. Kill Process
    indexDB基本用法
    浏览器的渲染原理
    js实现txt/excel文件下载
    git 常用命令
    nginx进入 配置目录时
  • 原文地址:https://www.cnblogs.com/111qqz/p/4891631.html
Copyright © 2011-2022 走看看