Codeforces Global Round 17 D. Not Quite Lee
violet_apricity
2021年11月24日 23:22
收录于文集
共10篇

D. Not Quite Lee : [ https://codeforces.com/contest/1610/problem/D ]

赛时没推出来,赛后浏览题解自己再推了一遍。数学公式太难编辑于是手写了。

题面

样例及解释

推理证明

代码:

代码块
C++
自动换行
复制代码
/*
 * @Autor: violet apricity ( Zhuangpx )
 * @Date: 2021-10-18 13:14:50
 * @LastEditors: violet apricity ( Zhuangpx )
 * @LastEditTime: 2021-11-24 19:36:53
 * @FilePath: \apricity\Zhuangpx.cpp
 * @Description:  Zhuangpx : Violet && Apricity:/ The warmth of the sun in the winter /
 */


#pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;
#define IOS std::ios::sync_with_stdio(false), std::cin.tie(0), std::cout.tie(0)
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f
typedef long long ll;
#define ull unsigned long long
//#define INF ~0ULL
// #define mod 99993


const ll N = 2e5 + 10;
const ll mod = 1e9 + 7;

ll f[N];

int main()
{
#ifdef LOCAL
    freopen("E:\\ACMdream\\in.txt", "r", stdin);
    freopen("E:\\ACMdream\\out.txt", "w", stdout);
#endif
    IOS;
    //==================================================
    f[0]=1;
    for(ll i=1;i<N;i++)f[i]=2*f[i-1]%mod;
    ll n;cin>>n;
    map<ll,ll>mp;
    for(ll i=1;i<=n;i++){
        ll d;cin>>d;
        ll cnt=0;
        while(!(d&1)){
            cnt++;d>>=1;
        }
        mp[cnt]++;
    }
    ll res=n-mp[0];
    ll ans=f[n]-1;
    for(ll i=1;i<=31;i++){
        if(mp[i]==0)continue;
        res-=mp[i];
        ans=(ans-f[mp[i]-1]*f[res])%mod;
    }
    ans=(ans+mod)%mod;
    cout<<ans<<'\n';
    //==================================================
    return 0;
}
复制成功