zoukankan      html  css  js  c++  java
  • 1012. 增长率问题

    Description

    有一个数列,它是由自然数组成的,并且严格单调上升。最小的数不小于S,最大的不超过T。现在知道这个数列有一个性质:后一个数相对于前一个数的增长率总是百分比下的整数(如5相对于4的增长率是25%,25为整数;而9对7就不行了)。现在问:这个数列最长可以有多长?满足最长要求的数列有多少个?

    Input Format

    输入仅有一行,包含S和T两个数( 0<S<T200000

    )。

    30%的数据,0<S<T100

    100%的数据,0<S<T200000

    Output Format

    输出有2行。第一行包含一个数表示长度,第二行包含一个数表示个数。

    Sample Input

    2 10
    

    Sample Output

    5
    2
    

    样例解释

    2 4 5 6 9以及2 4 5 8 10

    #include<iostream>
    #include<cstdio>
    #include<cstring>
    using namespace std;
    
    typedef long long ll;
    const int maxn=200007;
    int d[maxn];
    ll cnt[maxn],times[maxn];
    
    //cnt[i]存储长度为i的序列的个数
    //d[i]存储以i结尾的序列最长的长度
    
    int main(){
        int s,t;
        cin>>s>>t;
        memset(cnt,0,sizeof(cnt));
        int i,j,temp,anx=1;
        cnt[1]=t-s+1;
        for(i=s;i<=t;i++){
            d[i]=times[i]=1;
        }
        for(i=s;i<=t;i++){
            for(j=1;j<=100;j++){
                if((i*j)%100==0){
                    temp=i+i*j/100;
                    if(temp<=t){
                        if(d[i]+1>d[temp]){
                            d[temp]=d[i]+1;
                            times[temp]=times[i];
                        }
                        else if(d[i]+1==d[temp]){
                            times[temp]+=times[i];
                        }
                        anx=max(anx,d[temp]);
                        cnt[d[i]+1]+=times[i];
                    }
                }
            }
        }
        cout<<anx<<endl<<cnt[anx];
        return 0;
    } 
  • 相关阅读:
    SQL的update from 理解
    JS自动合并表格
    完全备份ORACLE数据库 并在另一台电脑上恢复
    cmd 连接到指定路径
    oracle 11g 64位安装sqldeveloper打开不了
    oracle 11g卸载方法
    sql的游标使用(转)
    JQEUERY案例
    sessionStorage实现note的功能
    Web Worker模拟抢票
  • 原文地址:https://www.cnblogs.com/bernieloveslife/p/7826569.html
Copyright © 2011-2022 走看看