結果

問題 No.685 Logical Operations
ユーザー 👑 tatyam
提出日時 2018-05-11 23:53:36
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 785 bytes
コンパイル時間 1,219 ms
コンパイル使用メモリ 158,440 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-28 09:05:51
合計ジャッジ時間 2,047 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 5 WA * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,l,r) for(ll i=(l);i<(r);i++)
ll mem[64][64],cnt[64];
ll nCm(ll n,ll m){
    if(n<m+m)return nCm(n,n-m);
    if(m==0||n==m)return 1;
    if(mem[n][m])return mem[n][m];
    mem[n][m]=nCm(n-1,m-1)+nCm(n-1,m);
    return mem[n][m];
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,a=1,power,ans=0;
    cin>>n;
    n++;
    for(int i=0;n;i++){
        a=1;
        power=0;
        while(a<<1<=n){
            a<<=1;
            power++;
        }
        n-=a;
        for(int j=0;j<=power;j++){
            cnt[j+i]+=nCm(power,j);
        }
    }
    for(int i=2;cnt[i];i++){
        ans+=cnt[i]*((int)pow(2,i-1)-1);
        ans%=1000000007;
    }
    cout<<ans<<endl;
    return 0;
}
0