結果
| 問題 |
No.411 昇順昇順ソート
|
| コンテスト | |
| ユーザー |
peroon
|
| 提出日時 | 2019-04-21 16:12:38 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 896 bytes |
| コンパイル時間 | 1,542 ms |
| コンパイル使用メモリ | 169,068 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-10-06 02:32:32 |
| 合計ジャッジ時間 | 2,296 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 30 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")
const int N_MAX = 21;
ll ll_pow(ll a, ll n){
ll ans = 1;
FOR(i, 0, n){
ans *= a;
}
return ans;
}
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
// input
ll N, K;
cin >> N >> K;
// パスカルの三角形を横に和をとったもの
vector<ll> P;
FOR(i, 0, N_MAX){
P.push_back(ll_pow(2, i));
}
ll sum = 0;
if(K==1){
FOR(i, 2, N){
sum += P[N-i] - 1;
}
}
else{
sum += P[N-K];
}
p(sum);
return 0;
}
peroon