首页
DreamJudge
院校信息
考研初试
机试真题
讨论区
兑换中心
登录
注册
上岸
以下题解仅供学习参考使用。
抄袭、复制题解,以达到刷AC率/AC数量或其他目的的行为,在N诺是严格禁止的。
N诺非常重视学术诚信。此类行为将会导致您成为作弊者。具体细则请查看N诺社区规则。
RingoCrystal
2025年2月11日 10:41
爬楼梯游戏 题解:为了防止爆内存,我们事先准备好数组
P1685
回复 0
|
赞 11
|
浏览 604
#include <bits/stdc++.h> using namespace std; const int p=1e9+7; int main() { std::vector<int> a(1000001); a[1]=1,a[2]=2; for(int i=3;i<=1000001;i++){ a[i]=(a[i-1]+a[i-2])%p; } int n; while(cin>>n){ cout<<a[n]<...
快乐小土狗
2024年4月6日 10:24
爬楼梯游戏 题解:C语言解法
P1685
回复 0
|
赞 2
|
浏览 1.1k
#include <stdio.h> int mod=1e9+7; int dp[1000005];//要先填充dp再进行多组输入,否则会超时 int main() { int n; dp[0]=1,dp[1]=1; for(int i=2;i<=1000000;i++) dp[i]=(dp[i-1]+dp[i-2])%mod; while(scanf("%d",&n)!=EOF) printf("%d\n",dp[n]); }
JohnWang
2021年4月23日 15:50
Java计算斐波那契数列
P1685
回复 0
|
赞 1
|
浏览 8.1k
import java.math.BigInteger; import java.util.Scanner; public class Main { static BigInteger fibo[] = new BigInteger[1000005]; public static BigInteger Fibonacci(int n) { if(fibo[n] != null) return fibo[n]; BigInteger b1 = BigInteger.ONE; BigInteger b2 = b1; BigInteger ...
chenziyi
2020年5月9日 22:34
又数据加强了吗 过不了50%
P1685
回复 2
|
赞 2
|
浏览 10.9k
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <string> #include <vector> using namespace std; const int maxn=1e6+1; const int p=1e9+7; int dp[maxn]; int main() { int n; while(cin>>n){ memset(dp, ...
Ang
2020年3月14日 19:20
签到题
P1685
回复 0
|
赞 3
|
浏览 10.3k
#include<bits/stdc++.h> using namespace std; int const maxn=1000001; int const p=1e9+7; int dp[maxn]; int main(){ dp[0]=0; dp[1]=1; dp[2]=2; for(int i=3;i<maxn;i++){ dp[i]=(dp[i-1]+dp[i-2])%p; } int x; while(scanf("%d",&x)!=EOF){ ...
题目
爬楼梯游戏
题解数量
5
发布题解
在线答疑
热门题解
1
爬楼梯游戏 题解:为了防止爆内存,我们事先准备好数组
2
签到题
3
又数据加强了吗 过不了50%
4
爬楼梯游戏 题解:C语言解法
5
Java计算斐波那契数列