-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathabs.cpp
More file actions
54 lines (53 loc) · 837 Bytes
/
abs.cpp
File metadata and controls
54 lines (53 loc) · 837 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
map<pair<ll,ll>,ll>dp;
ll n,k;
ll rec(ll sum,int idx)
{
ll res = 0;
if(idx==sum)
return 1;
if(idx>sum)
return 0;
if(dp.find(make_pair(sum,idx))!=dp.end())
return dp[make_pair(sum,idx)];
if(idx>=n)
{
if(sum==k)
return 1;
return 0;
}
if(idx<n)
{
res += rec(sum+1,idx+1);
res += rec(sum+2,idx+1);
res += rec(sum+3,idx+1);
res += rec(sum+4,idx+1);
res += rec(sum+5,idx+1);
res += rec(sum+6,idx+1);
}
return dp[make_pair(sum,idx)] = res;
}
int main()
{
int t;
cin>>t;
while(t--)
{
dp.clear();
cin>>n>>k;
if(n>k)
{
cout<<"0"<<endl;
continue;
}
ll ans = rec(0,0);
ll total = pow(6,n);
double answer = (double)ans/total;
answer = (double)answer*100;
ll answ = (ll)answer;
cout<<answ<<endl;
}
return 0;
}