50超loog loog了

P1255 数楼梯

Leo001 @ 2024-12-22 17:16:28

#include<iostream>
using namespace std;
int main()
{
    long long a=1,b=1,c;
    long long n;
    cin>>n;
    for(long long i=2;i<=n;i++)
    {
        c=a+b;
        a=b;
        b=c;
    }
    cout<<c;
}

by ___xuzhimo___ @ 2024-12-22 17:19:13

@Leo001当然


by Leo001 @ 2024-12-22 17:20:25

咋办?


by wyp20130701 @ 2024-12-22 17:23:56

@Leo001高精度算法


by wyp20130701 @ 2024-12-22 17:25:29

#include <iostream>
using namespace std;
short f[5005][5500];
void jia(int p1,int p2,int pd)
{
    short x = 0,len = 0;
    for (int i = 1;i <= 5499;i++)
    {
        f[pd][i] = f[p1][i] + f[p2][i] + x;
        x = f[pd][i] / 10;
        f[pd][i] %= 10;
        len++;
    }
    f[pd][len] = x;
    return ;
}
void print(int n,int pos)
{
    for (int i = pos;i >= 1;i--)
    {
        cout << f[n][i];
    }
    return ;
}
int main()
{
    f[1][1] = 1;
    f[2][1] = 2;
    int n;
    cin >> n;
    for (int i = 3;i <= n;i++)
    {
        jia(i - 1,i - 2,i);
    }
    short pos = 5499;
    while (f[n][pos] == 0)
    {
        pos--;
    }
    print(n,pos);
    return 0;
}

by pika_ @ 2024-12-22 17:30:43

python (doge


by pika_ @ 2024-12-22 17:31:26

还有就是 loog loog 是什么东西…


by Leo001 @ 2024-12-23 17:07:24

不小心打错了 是“long long”


|