結果
問題 |
No.2853 A + B Problem
|
ユーザー |
![]() |
提出日時 | 2024-08-25 13:46:06 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,095 bytes |
コンパイル時間 | 1,612 ms |
コンパイル使用メモリ | 169,576 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-08-25 13:46:09 |
合計ジャッジ時間 | 2,457 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 30 |
コンパイルメッセージ
main.cpp: In function 'll pow_mod(ll, ll)': main.cpp:46:1: warning: control reaches end of non-void function [-Wreturn-type] 46 | } | ^
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<(int)(n);i++) #define all(x) x.begin(), x.end() #define MOD1 1LL<<61-1 #define MOD2 (1LL<<61)-1 #define MOD3 (1LL<<61-1) using namespace std; using ll=long long; using ld=long double; using P=pair<ll,ll>; //#include <atcoder/all> //using namespace atcoder; ////using mint=static_modint<998244353>; //using mint=static_modint<1000000007>; ////using mint=modint; //#pragma GCC target("avx2") //#pragma GCC optimize("O3") //#pragma GCC optimize("unroll-loops") int inf=2147483647; ll INF=9223372036854775807; const ld PI=acos(-1); void yn(bool f){ if(f)cout<<"Yes"<<endl; else cout<<"No"<<endl; return; } string base10to2(ll n){ if(n==0)return "0"; string a=""; while(n>0){ a=char(n%2+'0')+a; n/=2; } return a; } ll pow_mod(ll n,ll k){ if(k==0)return 1; if(k%2==1)return pow_mod(n,k-1)*n; if(k%2==0){ ll t=pow_mod(n,k/2); return t*t; } } int main(){ ll n;cin>>n; string s=base10to2(n); ll a=0; rep(i,s.size())if(s[i]=='1')a++; cout<<pow_mod(2,a)-2<<endl; }