結果

問題 No.589 Counting Even
ユーザー Gurren47881
提出日時 2017-11-03 23:31:39
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 948 bytes
コンパイル時間 1,432 ms
コンパイル使用メモリ 166,856 KB
実行使用メモリ 6,784 KB
最終ジャッジ日時 2024-11-23 14:59:14
合計ジャッジ時間 7,652 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 5 WA * 3 RE * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
#define REP(i,n) for(int i = 0;i < (n);i++)
#define pb push_back

const int INF = 1e9;
 
const ll mod=1e9+7;
 
ll fact[200010];//階乗の値を保存
ll rfact[200010];//逆元の値を保存
 
ll mod_pow(ll x, ll p){
        ll res=1;
        while(p){
                if(p&1){
                        res=res*x%mod;
                }
                x=x*x%mod;
                p/=2;
        }
        return res;
}
 
ll nCr(ll n, ll r){
        return fact[n]*rfact[r]%mod*rfact[n-r]%mod;
}

int main(){
  fact[0]=1;
  rfact[0]=1;
  for(int i=1;i<200010;i++){
    fact[i]=i*fact[i-1]%mod;
    rfact[i]=mod_pow(fact[i], mod-2);
  }
  ll n;
  ll sum = 0;
  cin >> n;
  REP(i,n/2+1){
    ll a = nCr(n,i);
    if(a%2 == 0)
      sum++;
    
  }
  if(n%2 == 0 && n != 0)
    cout << (sum-1)*2+1 << endl;
  else if(n == 0)
    cout << 0 << endl;
  else
    cout << sum*2 << endl;
}
0