首页
DreamJudge
院校信息
考研初试
考研复试
保研专区
讨论区
兑换中心
登录
注册
上岸
以下题解仅供学习参考使用。
抄袭、复制题解,以达到刷AC率/AC数量或其他目的的行为,在N诺是严格禁止的。
N诺非常重视学术诚信。此类行为将会导致您成为作弊者。具体细则请查看N诺社区规则。
曾不会
2026年3月22日 16:39
吃糖果 题解:
P1197
回复 0
|
赞 0
|
浏览 30
#include<stdio.h> int main() { long long a[25]; a[1]=1; a[2]=2; a[3]=3; a[4]=5; for(int i=5;i<24;i++) { a[i...
2022214449
2026年3月21日 13:03
吃糖果 题解:
P1197
回复 0
|
赞 1
|
浏览 49
#include <iostream> #include <bits/stdc++.h> using namespace std; int tangguo(int n){ if(n==1) return 1; if(n==2) return 2; else return tangguo(n-1)+tangguo(n-2); } int main() { int n; while(cin>>n){ cout&...
彻底死去
2026年3月19日 17:57
吃糖果 题解:
P1197
回复 0
|
赞 1
|
浏览 61
#include<iostream> #include<cstdio> #include<cmath> #include<algorithm> #include<string> #include<cstring> using namespace std; int main() { int n; while (cin >> n) { int arr[1000]; arr[0] = 1, arr[1] = 2; f...
太一
2026年3月18日 16:51
吃糖果 题解 递归
P1197
回复 0
|
赞 2
|
浏览 47
#include<iostream> #include<cmath> #include<algorithm> #include<string> #include<map> using namespace std; int sum(int n) { if (n < 2) { return 1; } return sum(n - 1) + sum(n - 2); } int main() { int n; while (cin >&g...
Jinx_K
2026年3月13日 14:47
吃糖果 题解:
P1197
回复 0
|
赞 0
|
浏览 29
#include <iostream> using namespace std; int main() { int N; while(cin>>N) { int number[25]={0}; number[1]=1; number[2]=2; int x=2; if(N>2) while(x++!=N) number[x]=number[x-1]+number[x-2]; cout<<number[N]<<endl; } return 0; }...
uly
2026年3月8日 13:19
吃糖果 题解:
P1197
回复 0
|
赞 3
|
浏览 141
#include <bits/stdc++.h> using namespace std; long long candy[100]; int main() { candy[1] = 1; candy[2] = 2; for (int i = 3; i < 100; i++) { candy[i] = candy[i - 1] + candy[i - 2]; } int n; while (cin >> n) { cout << cand...
bro
2026年3月5日 15:51
吃糖果 题解:c++
P1197
回复 0
|
赞 2
|
浏览 88
#include <bits/stdc++.h> using namespace std; int main(){ int n; while(cin >> n){ long long num[100] = {}; num[1] = 1; num[2] = 2; for(...
yauqq
2026年2月9日 09:58
吃糖果 题解:
P1197
回复 0
|
赞 1
|
浏览 181
#include<bits/stdc++.h> using namespace std; int main(){ int n; while(cin >> n){ int a[20]; a[1] = 1; a[2] = 2; for(int i=3;i<=n;i++) a[i] = a[i-1] + a[i-2]; cout << a[n] << endl; } return 0; }
mlx
2026年2月8日 22:23
吃糖果 题解:
P1197
回复 0
|
赞 0
|
浏览 180
#include<iostream> using namespace std; int n,res; void dfs(int num) { if(num>n) return; if(num==n) { res++; return; } dfs(num+1); dfs(num+2); } int main() { while(cin>>n) { res=0; dfs(0); cout<<res<<endl; } } ...
GENARDING
2025年3月11日 20:19
动态规划
P1197
回复 0
|
赞 5
|
浏览 1.8k
#include <bits/stdc++.h> using namespace std; int main() { int n; while(cin>>n){ int dp[n+1]; dp[0]=1; dp[1]=1; for(int i=2;i<=n;i++){ dp[i]=dp[i-1]+dp[i-2]; } cout<<dp[n]<<endl; } }
1
2
3
题目
吃糖果
题解数量
21
发布题解
在线答疑
热门题解
1
吃糖果(和斐波那契数列递推差不多) 题解:
2
1197 吃糖果 北京大学签到题
3
动态规划
4
吃糖果方案,n个糖果可以一天吃1或2个,问有几种吃法
5
吃糖果 题解:动态规划
6
吃糖果 题解:
7
吃糖果 题解 递归
8
吃糖果 题解:O(1)空间复杂度,内存140kb
9
吃糖果 题解:c++
10
吃糖果 题解: