➤ Problem Link : SAMER08F
👉 Hint : Simple 2D DP
✅ C++ Solution :
#include<bits/stdc++.h> using namespace std; int main() { long long int dp[101][101]; while(1) { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin>>n; if(n==0) break; long long int ans=0; for(int i=1;i<=n;i++) { for(int j=1;j<=n;j++) { ans+=min(i,j); dp[i][j]=ans; } } cout<<dp[n][n]<<endl; } return 0; }
Thank you for your patience reading. If you enjoyed this post, I’d be very grateful if you’d help it spread by emailing it to a friend, or sharing it on Whatsapp or Facebook.
😇Happy Learning!!