'commit'
This commit is contained in:
25
TangDou/LuoGuBook/P1028_0.cpp
Normal file
25
TangDou/LuoGuBook/P1028_0.cpp
Normal file
@@ -0,0 +1,25 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
int n;
|
||||
|
||||
//毫不意外,只通过了5个测试点,TLE了15个点~
|
||||
int dfs(int x) {
|
||||
//1就没法继续分了,同时,由于题目说:原数列不做任何修改就直接统计为一种合法数列。所以返回1
|
||||
if (x == 1) return 1;
|
||||
|
||||
//不是1,可以分
|
||||
int ans = 1;//它自己就是一种
|
||||
//在它后面不断加入[1,x/2]的数字,都可以增加方法数量
|
||||
for (int i = 1; i <= x / 2; i++) ans += dfs(i);
|
||||
//返回方法数量
|
||||
return ans;
|
||||
}
|
||||
|
||||
int main() {
|
||||
//输入
|
||||
cin >> n;
|
||||
//计算并输出
|
||||
cout << dfs(n) << endl;
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user