結果
問題 | No.420 mod2漸化式 |
ユーザー | femto |
提出日時 | 2016-09-09 22:49:18 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 1,000 ms |
コード長 | 1,034 bytes |
コンパイル時間 | 1,157 ms |
コンパイル使用メモリ | 89,324 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-12-24 11:03:34 |
合計ジャッジ時間 | 2,043 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 35 |
ソースコード
#include <iostream> #include <fstream> #include <vector> #include <cstring> #include <string> #include <algorithm> #include <iomanip> #include <map> using namespace std; typedef long long ll; ll p[11] = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31 }; ll comb(int n, int x) { map<ll, int> m; for(int i = n; i >= n - x + 1; i--) { ll y = i; for(int j = 0; j < 11; j++) { while(y % p[j] == 0) { m[p[j]]++; y /= p[j]; } } } for(int i = 1; i <= x; i++) { ll y = i; for(int j = 0; j < 11; j++) { while(y % p[j] == 0) { m[p[j]]--; y /= p[j]; } } } ll ret = 1; for(auto v : m) { for(int i = 0; i < v.second; i++) { ret *= v.first; } } return ret; } int main() { cin.tie(0); ios::sync_with_stdio(false); ll x; cin >> x; if(x > 31) { cout << "0 0" << endl; return 0; } if(x == 0) { cout << "1 0" << endl; return 0; } ll ans1 = comb(31, x); ll ans2 = 0; for(int i = 0; i < 31; i++) { ans2 += (1LL << i) * comb(30, x - 1); } cout << ans1 << " " << ans2 << endl; }