2 条题解
-
0马睿 (2024sng28) LV 10 @ 2025-1-30 18:34:28
数学AC解法(QWQ累死了)
#include<bits/stdc++.h> using namespace std; const int N=1e5+5,INF=0x3f3f3f3f; typedef long long LL; int n,m; int f(int n,int m){ if(m==1||n==m)return 1; else if(m>n)return 0; else return f(n-1,m-1)+f(n-m,m); } int main() { cin>>n>>m; cout<<f(n,m); return 0; }
人家费了好大力气算出来的(给个点赞吧)
-
02022-4-9 12:00:37@
#include <queue> #include <math.h> #include <stack> #include <stdio.h> #include <iostream> #include <vector> #include <iomanip> #include <string.h> #include <algorithm> #include<bits/stdc++.h> using namespace std; #define LL long long const int N=1e5+10; const int INF=0x3f3f3f3f; int ans; void f(int n,int m,int last) { if(m*last>n) return; if(m==1) { ans++; return; } for(int i=last;i <n;i++) f(n-i,m-1,i); } int main() { int n,m; cin>>n>>m; f(n,m,1); cout<<ans<<endl; return 0; }
- 1
信息
- ID
- 1485
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 4
- 标签
- 递交数
- 116
- 已通过
- 53
- 上传者