mirror of
https://github.com/wczffl-503/OI-Codes.git
synced 2025-07-07 18:06:58 +08:00
Upload via code
This commit is contained in:
24
FZOI/「NOIP2001」数的划分.cpp
Normal file
24
FZOI/「NOIP2001」数的划分.cpp
Normal file
@ -0,0 +1,24 @@
|
||||
#include <bits/stdc++.h>
|
||||
#define int long long
|
||||
using namespace std;
|
||||
|
||||
int n, k, cnt;
|
||||
|
||||
void dfs(int last, int sum, int cur)
|
||||
{
|
||||
if (cur == k)
|
||||
{
|
||||
if (sum == n)
|
||||
cnt++;
|
||||
return;
|
||||
}
|
||||
for (int i = last; sum + i * (k - cur) <= n; i++)
|
||||
dfs(i, sum + i, cur + 1);
|
||||
}
|
||||
|
||||
signed main()
|
||||
{
|
||||
cin >> n >> k ;
|
||||
dfs(1, 0, 0);
|
||||
cout << cnt ;
|
||||
}
|
Reference in New Issue
Block a user