結果
問題 | No.976 2 の 128 乗と M |
ユーザー | risujiroh |
提出日時 | 2020-01-31 21:30:05 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 575 bytes |
コンパイル時間 | 1,655 ms |
コンパイル使用メモリ | 167,428 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-17 07:13:58 |
合計ジャッジ時間 | 2,923 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 50 |
ソースコード
#include <bits/stdc++.h> using namespace std; template <class T, class F = multiplies<T>> T power(T a, long long n, F op = multiplies<T>(), T e = {1}) { assert(n >= 0); T res = e; while (n) { if (n & 1) res = op(res, a); if (n >>= 1) a = op(a, a); } return res; } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); long long m; cin >> m; auto add = [&](long long l, long long r) { return (l + r) % m; }; auto mul = [&](long long l, long long r) { return power(l, r, add, 0LL); }; cout << power(2LL, 128, mul) << '\n'; }