解题思路:
dfs 得到 数据:0-1000 的答案, 然后 ,打表求解:
注意事项:
dfs 打表 可分 多个 cpp 来打表
参考代码:
得到 答案 :
dfs 得到 1000的数据
#include<bits/stdc++.h> using namespace std; long long ans = 0; long long rec[1001]; void dfs(int n, int pos) { long long sum = 0; if (pos == 1 && n>0) { ans++; return; }; for (int i = 1; i <= n - pos + 1; ++i) if (rec[n - 1])ans += rec[n]; else dfs(n - i, pos - 1); } int main() { int n; for (int i = 0; i <= 1000; ++i) { dfs(i, 4); cout << ans << "," << endl; ans = 0; } return 0; }
最终代码:
#include<bits/stdc++.h> using namespace std; long long rec={ 答案 表 }; int main() { int n,t; cin>>n; while(n--){ cin>>t; cout<<rec[t]<<endl; } return 0; }
来自我 的第一篇 题解
0.0分
0 人评分
printf基础练习2 (C语言代码)浏览:305 |
C语言程序设计教程(第三版)课后习题6.4 (C语言代码)浏览:1030 |
C语言程序设计教程(第三版)课后习题6.9 (C语言代码)浏览:763 |
C语言程序设计教程(第三版)课后习题1.6 (C语言代码)浏览:694 |
C语言程序设计教程(第三版)课后习题8.3 (C语言代码)浏览:1091 |
C语言程序设计教程(第三版)课后习题10.4 (C语言代码)浏览:535 |
C语言程序设计教程(第三版)课后习题5.6 (C语言代码)浏览:531 |
简单的a+b (C语言代码)浏览:946 |
复数求和 (C语言代码)浏览:920 |
输出九九乘法表 (C语言代码)浏览:1048 |