zoukankan      html  css  js  c++  java
  • 数字(number)

    数字(number) 

    Time Limit:2000ms   Memory Limit:128MB

    题目描述

    LYK定义了一个新的计算。

    具体地,一开始它有两个数字a和b。

    每一步,它可以将b增加1,或者将a乘上b。

    也就是说(a,b)经过一次操作后可以变成(a,b+1)或者(a*b,b)。再经过一次操作可以变成(a,b+2)或者(a*(b+1),b+1)或者(a*b,b+1)或者(a*b*b,b)。接下来都类似……它认为只有在这个括号左侧的数字才是有意义的,并且它想执行的操作数不会很多。

    具体的,如果LYK能通过不超过p步,使得这个括号内左侧的数字变成x,那么x就是一个有意义的数字!

    zhw觉得这个题目太难了,会为难大家,于是他将这个问题中初始的a定义为了1,把b定义为了0。

    LYK想知道在一段区间[L,R]中,存在多少有意义的数字。

    输入格式(number.in)

    第一行3个数分别表示L,R,p。

    输出格式(number.out)

    一个数表示答案。

    输入样例1

    1 100 10

    输出样例1

    46

    输入样例2

    233 233333333 50

    输出样例2

    332969

    数据范围

    对于30%的数据L,R<=10。

    对于另外20%的数据p<=20。

    对于70%的数据1<=L<=R<=10001<=p<=50。

    对于90%的数据1<=L<=R<=10000001<=p<=50。

    对于100%的数据1<=L<=R<=5000000001<=p<=50。

      搜索白,但只有90分

    #include<iostream>
    #include<cstdio>
    #include<algorithm>
    #include<cstring>
    #include<queue>
    #include<math.h>
    #include<vector>
    using namespace std;
    #define LL long long
    int l,r,p,ans;
    bool f[2000000];
    void  dfs(int a,int b,int x)
    {
        if(a>=l&&a<=r)    f[a]=true;
        if(1LL*a*b>r)    return;
        if(x>=p)    return;
        dfs(a*b,b,x+1);dfs(a,b+1,x+1);
    } 
    int main()
    {
        freopen("number.in","r",stdin);    freopen("number.out","w",stdout);
        scanf("%d%d%d",&l,&r,&p);
        dfs(1,1,1);
        for(int i=l;i<=r;i++)
            if(f[i])    ans++;    
        cout<<ans;
        return 0;
    }
  • 相关阅读:
    JavaScript中的闭包
    SQL 备忘
    SqlServer 2005 升级至SP2过程中出现"身份验证"无法通过的问题
    unable to start debugging on the web server iis does not list an application that matches the launched url
    Freebsd 编译内核
    Freebsd 6.2中关于无线网络的设定
    【Oracle】ORA01219
    【Linux】Windows到Linux的文件复制
    【Web】jar命令行生成jar包
    【Linux】CIFS挂载Windows共享
  • 原文地址:https://www.cnblogs.com/CLGYPYJ/p/7228901.html
Copyright © 2011-2022 走看看