結果
問題 |
No.2853 A + B Problem
|
ユーザー |
![]() |
提出日時 | 2024-08-25 16:08:27 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,879 bytes |
コンパイル時間 | 1,949 ms |
コンパイル使用メモリ | 193,400 KB |
最終ジャッジ日時 | 2025-02-24 01:44:05 |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 28 WA * 2 |
ソースコード
#include <bits/stdc++.h> //#include <atcoder/all> //using namespace atcoder; //using mint = modint998244353; using namespace std; using ll= long long; using ull=unsigned long long; using ldo =long double; #define rep(i,n,k) for(ll i = k; i < (ll)(n); i++) template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; } template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; } const ll INF = 1e18; struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star; #define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++) // 考える整数の最大値 const int MAX = 500000; // 今回採用する大きい素数 const int MOD = 1000000007; // メモを保管する場所 ll fact[MAX], inv_fact[MAX], inv[MAX]; // メモを計算する void init() { // 初期値設定と1はじまりインデックスに直す fact[0] = 1; fact[1] = 1; inv[0] = 1; inv[1] = 1; inv_fact[0] = 1; inv_fact[1] = 1; // メモの計算 repi(i, 2, MAX){ // 階乗 fact[i] = fact[i - 1] * i % MOD; // 逆元 inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD; // 逆元の階乗 inv_fact[i] = inv_fact[i - 1] * inv[i] % MOD; } } // 二項係数の実体 ll nCk(int n, int k) { ll x = fact[n]; // n!の計算 ll y = inv_fact[n-k]; // (n-k)!の計算 ll z = inv_fact[k]; // k!の計算 if (n < k) return 0; // 例外処理 if (n < 0 || k < 0) return 0; // 例外処理 return x * ((y * z) % MOD) % MOD; //二項係数の計算 } int main(){ init(); ll N,B,ans=0,co,z; cin>>N; bitset<61> bs(N); //cout << bs << endl; co=bs.count(); rep(i,co,1){ if(co-i<i)z=co-i; else z=i; //cout<<co<<" "<<z<<endl; //cout<<nCk(co,z)<<endl; ans+=nCk(co,z); } cout<<ans<<endl; }