結果
問題 | No.420 mod2漸化式 |
ユーザー |
|
提出日時 | 2016-09-10 23:29:27 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 1,000 ms |
コード長 | 881 bytes |
コンパイル時間 | 1,035 ms |
コンパイル使用メモリ | 72,784 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-24 11:31:58 |
合計ジャッジ時間 | 1,889 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 35 |
ソースコード
#include <iostream>#include <cstdio>#include <vector>#include <algorithm>#include <utility>#include <numeric>using namespace std;void check(int n) {vector<int> f(n+1, 0);for (int i = 1; i <= n; i++) {f[i] = f[i/2] + (i%2);}for (int i = 0; i <= n; i++) {printf("%2d, %2d\n", i, f[i]);}}int main() {// check(100);int x;cin >> x;if (x > 31) {cout << "0 0" << endl;return 0;}vector<int> nums(x);for (int i = 0; i < x; i++) {nums[i] = 31 - i;}int gcd;for (int i = x; i >= 2; i--) {int tmp = i;for (int j = 0; j < x; j++) {gcd = __gcd(nums[j], tmp);nums[j] /= gcd;tmp /= gcd;if (tmp == 1) {break;}}}long long n = accumulate(nums.begin(), nums.end(), 1LL, std::multiplies<long long>());long long val = n * x / 31;val *= (1LL << 31) - 1;cout << n << " " << val << endl;return 0;}