美文网首页
2020-08-20 蜜蜂线路

2020-08-20 蜜蜂线路

作者: JalorOo | 来源:发表于2020-08-20 21:39 被阅读0次

    https://www.luogu.com.cn/problem/P2437

    #include <iostream>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <sstream>
    #include <algorithm>
    #include <cstring>
    #include <vector>
    using namespace std;
    
    long long qmi(int m, int k)
    {
        int res = 1, t = m;
        while (k)
        {
            if (k&1) res = res * t;
            t = t * t;
            k >>= 1;
        }
        return res;
    }
    
    int read(){
        int x = 0,f = 1;
        char c = getchar();
        while (c<'0'||c>'9') {
            if (c=='-') {
                f = -1;
            }
            c = getchar();
        }
        while (c>='0'&&c<='9') {
            x = x*10+c-'0';
            c = getchar();
        }
        return x*f;
    }
    
    struct Wint:vector<int>//高精度模板
    {
        Wint(int n=0)
        {
            push_back(n);
            check();
        }
        Wint& check()
        {
            for(int i=1; i<size(); ++i)
            {
                (*this)[i]+=(*this)[i-1]/10;
                (*this)[i-1]%=10;
            }
            while(back()>=10)
            {
                push_back(back()/10);
                (*this)[size()-2]%=10;
            }
            return *this;
        }
    };
    istream& operator>>(istream &is,Wint &n)
    {
        string s;
        is>>s;
        n.clear();
        for(int i=s.size()-1; i>=0; --i)n.push_back(s[i]-'0');
        return is;
    }
    ostream& operator<<(ostream &os,const Wint &n)
    {
        if(n.empty())os<<0;
        for(int i=n.size()-1; i>=0; --i)os<<n[i];
        return os;
    }//输入输出
    Wint& operator+=(Wint &a,const Wint &b)
    {
        if(a.size()<b.size())a.resize(b.size());
        for(int i=0; i!=b.size(); ++i)a[i]+=b[i];
        return a.check();
    }
    Wint operator+(Wint a,const Wint &b)
    {
        return a+=b;
    }//写A+B Problem...
    /*以上皆是用重载运算符实现的高精*/
    Wint f[1005]={0,1,1};//进行赋初值,f[1]=f[2]=1
    int main(){
        int m,n;
        cin>>m>>n;
        for(int i=3;i<=n-m+1;++i)    f[i]=f[i-1]+f[i-2];//进行递推
        cout<<f[n-m+1];//输出答案
        return 0;
    }/*
    1 14
    ============
    377
    */
    

    相关文章

      网友评论

          本文标题:2020-08-20 蜜蜂线路

          本文链接:https://www.haomeiwen.com/subject/szoejktx.html