50分代码有啥问题
  • 板块P1255 数楼梯
  • 楼主Miquella
  • 当前回复4
  • 已保存回复4
  • 发布时间2020/11/14 20:25
  • 上次更新2023/11/5 08:03:32
查看原帖
50分代码有啥问题
367436
Miquella楼主2020/11/14 20:25

萌新提问,目前没学高精度,只用这种方法,只能得50,求帮助,前一种方法事40分的,用递归做的

#include <iostream>
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include<bits/stdc++.h>
//welcome to C++
//made from StarYi
using namespace std;
//int AC(int a)
//{
//	if(a == 1)
//	{
//		return 1;
//	}
//	if(a == 2)
//	{
//		return 2;
//	}
//	else
//	{
//		return AC(a-1)+AC(a-2);
//	}
//}
//int main()
//{
//  int n;
//  cin>>n;
//  cout<<AC(n);
//  return 0;
//}
int main()
{
	int n;
	cin>>n;
	int arr[100001];
	memset(arr,0,sizeof(arr));
	arr[1] = 1;
	arr[2] = 2;
	for(int i = 3;i<=n;i++)
	{
		arr[i] = arr[i-1]+arr[i-2];
	}
	cout<<arr[n];
	return 0;
}
2020/11/14 20:25
加载中...