C++ :
#include<bits/stdc++.h> #define M 505 using namespace std; long long dp[M]; int main(){ int n; cin >> n; dp[0] = 1; for (int i = 1;i<=n;i++){ for (int j = n;j>=i;j--){ dp[j] = dp[j] + dp[j-i]; } } cout << dp[n] - 1; return 0; }
By signing up a 大飞信奥 universal account, you can submit code and join discussions in all online judging services provided by us.
Using your 大飞信奥 universal account