➤ Problem Link : AE2A
👉 Hint : edit please
✅ C++ Solution :
#include<bits/stdc++.h> using namespace std; #define ld double ld dp[545][1908]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int t; cin>>t; while(t--) { int n,k; cin>>n>>k; if(n>545 || k>1908) { cout<<"0"<<endl; continue; } memset(dp,0,sizeof(dp)); for(int i=1;i<=6;i++) dp[0][i]=(ld)1/6; for(int i=1;i<n;i++) { for(int j=i;j<=k;j++) { for(int t=1;t<=6 && t<j;t++) dp[i][j]+=((ld)1/6)*dp[i-1][j-t]; } } cout<<(long long int)(dp[n-1][k]*100)<<"\n"; } }
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!!