/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 4ms 1.973 MiB
#2 Wrong Answer 4ms 2.02 MiB
#3 Wrong Answer 5ms 1.992 MiB
#4 Accepted 5ms 2.004 MiB
#5 Wrong Answer 5ms 2.023 MiB
#6 Accepted 5ms 1.84 MiB
#7 Accepted 5ms 2.086 MiB
#8 Accepted 5ms 2.02 MiB
#9 Accepted 4ms 2.086 MiB
#10 Accepted 5ms 1.852 MiB
#11 Wrong Answer 5ms 2.09 MiB
#12 Accepted 5ms 2.062 MiB
#13 Accepted 5ms 2.02 MiB
#14 Accepted 5ms 1.816 MiB
#15 Accepted 5ms 2.09 MiB

Code

#include <bits/stdc++.h>
//#define ll long long int

using namespace std;
typedef long long int ll;
priority_queue<int, vector<int>, greater<int>> pq;
const ll md = 1e9 + 7;
const ll md1 = 998244353;
map<ll, vector<ll>> tree;
//map<ll, int> mp;
ll dp[200001];
ll mp(ll x,ll y,ll p){
	ll res=1;
	x=x%p;
	while(y>0){
		if(y&1)res=(res*x)%p;
		y=y>>1;
		x=(x*x)%p;
	}
	return res;

}
ll ncr(ll n,ll r){
ll x=dp[n];
ll y=(dp[n-r]*dp[r])%md;
x=((x%md)*(mp(y,md-2,md)%md))%md;
return x;

}
ll power(ll base,ll pw){
ll res=1;
while(pw>0){
    if(pw%2==0){
       base=((base%md)*(base%md))%md;
        pw/=2;
    }
    else{
        res=((res%md)*(base)%md)%md;
        pw--;
    }
}
return res;

}
void sufi() {
ll n,k;
cin>>n>>k;
ll ara[n+1];
ll cnt1=0;
ll cnt2=0;
for(int i=1;i<=n;i++){
    cin>>ara[i];
    if(ara[i]==1)cnt1++;
    else cnt2++;
}
ll ans=0;
for(ll i=k;i<=cnt1;i++){
    ans=((ans%md)+ncr(cnt1,i))%md;
}
ll tmp=power(2ll,cnt2);
ans=((ans%md)*tmp%md)%md;
ans=(ans-1+md)%md;
cout<<ans<<endl;

}
int main() {
    int t;
cin>>t;
dp[1]=1;
dp[0]=1;
for(ll i=2;i<=200000;i++){
    dp[i]=((i%md)*(dp[i-1]%md))%md;
}
    while (t--) {
        sufi();
       tree.clear();
        //mp.clear();
    }
    return 0;
}

Information

Submit By
Type
Submission
Problem
P1093 Number of Ways (Easy version)
Contest
Brain Booster #5
Language
C++20 (G++ 13.2.0)
Submit At
2024-09-05 16:45:03
Judged At
2024-10-03 13:06:19
Judged By
Score
81
Total Time
5ms
Peak Memory
2.09 MiB