結果
| 問題 | No.444 旨味の相乗効果 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-12-27 21:42:02 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,125 bytes |
| 記録 | |
| コンパイル時間 | 2,430 ms |
| コンパイル使用メモリ | 172,788 KB |
| 最終ジャッジ日時 | 2025-02-25 06:15:42 |
| 合計ジャッジ時間 | 3,065 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
In file included from /usr/include/c++/13/string:43,
from /usr/include/c++/13/bitset:52,
from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:52,
from main.cpp:3:
/usr/include/c++/13/bits/allocator.h: In destructor ‘std::_Vector_base<int, std::allocator<int> >::_Vector_impl::~_Vector_impl()’:
/usr/include/c++/13/bits/allocator.h:184:7: error: inlining failed in call to ‘always_inline’ ‘std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = int]’: target specific option mismatch
184 | ~allocator() _GLIBCXX_NOTHROW { }
| ^
In file included from /usr/include/c++/13/vector:66,
from /usr/include/c++/13/queue:63,
from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:157:
/usr/include/c++/13/bits/stl_vector.h:133:14: note: called from here
133 | struct _Vector_impl
| ^~~~~~~~~~~~
ソースコード
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int add(int a, int b) {
return (a += b) >= mod ? a - mod : a;
}
int mul(int a, int b) {
return 1LL * a * b % mod;
}
void upd(int &a, int b) {
if ((a += b) >= mod) {
a -= mod;
}
}
int modpow(int a, long long b) {
int ret = 1;
while (b > 0) {
if (b & 1) {
ret = 1LL * ret * a % mod;
}
a = 1LL * a * a % mod;
b >>= 1;
}
return ret;
}
int main() {
int n;
long long c;
cin >> n >> c;
int foo = 0;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
upd(foo, mod - modpow(a[i], c));
}
vector<int> dp(n * 2);
dp[0] = 1;
// doubling
for (int ii = 0; ii < 61; ii++) {
for (int i = 0; i < n; i++) {
for (int j = dp.size() - 2; j >= 0; j--) {
upd(dp[j + 1], mul(dp[j], a[i]));
}
}
int k;
for (int j = (c & 1); j < dp.size(); j += 2) {
k = j / 2;
dp[k] = dp[j];
}
for (k++; k < dp.size(); k++) {
dp[k] = 0;
}
for (int i = 0; i < n; i++) {
a[i] = mul(a[i], a[i]);
}
c >>= 1;
}
cout << add(dp[0], foo) << endl;
}