解题思路:
虽然提交错误,但我也把代码贴出来;这里我处理了重叠子问题;提高了效率; 但是就是不通过。
注意事项:
参考代码:
#include <cstdio> #include <cstring> #include <string> #include <cmath> #include <functional> #include <iostream> #include <algorithm> using namespace std; int dp[1001]={0}; int f(int i) { if(dp[i] > 0) { return dp[i]; } else { return dp[i] = (i == 1 ? 10 : (f(i-1) + 2)); } } int main() { int N; scanf("%d", &N); printf("%d\n", f(N)); return 0; }
0.0分
0 人评分
C语言程序设计教程(第三版)课后习题6.3 (C语言代码)from DQM浏览:671 |
P1000 (C语言代码)浏览:877 |
蚂蚁感冒 (C语言代码)浏览:1335 |
蓝桥杯历届试题-翻硬币 (C++代码)浏览:892 |
妹子杀手的故事 (C语言代码)浏览:1055 |
理财计划 (C语言代码)浏览:468 |
1025题 初学者,求帮忙看下,不知道哪错了浏览:316 |
P1002 (C++代码)浏览:717 |
删除数组中的0元素 (C语言代码)浏览:2043 |
Manchester-数字整除最原始易理解方法浏览:4485 |