zty_luogu @ 2021-08-03 19:49:13
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int f[5002][1020]={{},{0,1},{0,2}};
int arrlen(int a[]){
int i=0;
while(a[i]!=0) i++;
return i;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n;
int len=1;
cin>>n;
if(n==0)
{
cout<<0;
return 0;
}
for(int i=3;i<=n;i++)
{
for(int j=1;j<=len;j++)
{
f[i][j]=f[i-1][j]+f[i-2][j];
}
for(int j=1;j<=len;j++)
{
if(f[i][j]>=10)
f[i][j+1]+=f[i][j]/10,f[i][j]%=10;
}
if(f[i][len+1]>0)len++;
}
for(int i=len;i>=1;i--)
cout<<f[n][i];
return 0;
}
CE了为什么,求助
by zty_luogu @ 2021-08-03 19:49:54
数组开小大数据过不掉
开大了CE
by 0x3b800001 @ 2021-08-03 19:54:09
@zty_luogu 方法错了awa
by zty_luogu @ 2021-08-03 20:11:47
@x_y_f 哈?
f[i][j]=f[i-1][j]+f[i-2][j];
by 0x3b800001 @ 2021-08-03 20:14:12
@zty_luogu 只需要一个状态
你这样
by zty_luogu @ 2021-08-03 20:20:10
@x_y_f 关键要用高精度啊
n能取5000的
取5000答案是
6276302800488957086035253108349684055478528702736457439025824448927937256811663264475883711527806250329984690249846819800648580083040107584710332687596562185073640422286799239932615797105974710857095487342820351307477141875012176874307156016229965832589137779724973854362777629878229505500260477136108363709090010421536915488632339240756987974122598603591920306874926755600361865354330444681915154695741851960071089944015319300128574107662757054790648152751366475529121877212785489665101733755898580317984402963873738187000120737824193162011399200547424034440836239726275765901190914513013217132050988064832024783370583789324109052449717186857327239783000020791777804503930439875068662687670678802914269784817022567088069496231111407908953313902398529655056082228598715882365779469902465675715699187225655878240668599547496218159297881601061923195562143932693324644219266564617042934227893371179832389642895285401263875342640468017378925921483580111278055044254198382265567395946431803304304326865077742925818757370691726168228648841319231470626
必须高精
by 0x3b800001 @ 2021-08-03 20:22:52
@zty_luogu 哦
我睿智了
那滚动数组
by zty_luogu @ 2021-08-03 20:28:14
@x_y_f
感谢,我来试试
话说一道红牌题硬是给强化到了至少黄牌
by zty_luogu @ 2021-08-03 20:30:22
@x_y_f
问题来了,滚动数组的话要拷贝数字串 就会:
TLE:Time Limit Enough,时间充裕。
by 0x3b800001 @ 2021-08-03 20:31:59
@zty_luogu 人生苦短,我用py
by zty_luogu @ 2021-08-03 20:35:31
@x_y_f
......
/头秃
这题怕不是bug
22k通过哪来的