結果
| 問題 |
No.1540 級数おもちゃ
|
| コンテスト | |
| ユーザー |
Re_menal2
|
| 提出日時 | 2021-04-29 00:24:56 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,519 bytes |
| コンパイル時間 | 1,973 ms |
| コンパイル使用メモリ | 174,424 KB |
| 実行使用メモリ | 9,984 KB |
| 最終ジャッジ日時 | 2024-11-22 04:27:31 |
| 合計ジャッジ時間 | 7,412 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 2 |
| other | WA * 31 |
コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/istream:39,
from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/sstream:38,
from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/complex:45,
from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/ccomplex:39,
from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/x86_64-pc-linux-gnu/bits/stdc++.h:54,
from main.cpp:1:
In member function 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long int) [with _CharT = char; _Traits = std::char_traits<char>]',
inlined from 'int main()' at main.cpp:49:16:
/home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/ostream:167:25: warning: 'b' may be used uninitialized [-Wmaybe-uninitialized]
167 | { return _M_insert(__n); }
| ~~~~~~~~~^~~~~
main.cpp: In function 'int main()':
main.cpp:42:11: note: 'b' was declared here
42 | long a, b, c = 0;
| ^
In member function 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long int) [with _CharT = char; _Traits = std::char_traits<char>]',
inlined from 'int main()' at main.cpp:49:11:
/home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/ostream:167:25: warning: 'a' may be used uninitialized [-Wmaybe-uninitialized]
167 | { return _M_insert(__n); }
| ~~~~~~~~~^~~~~
main.cpp: In function 'int main()':
main.cpp:42:8: note: 'a' was declared here
42 | long a, b, c = 0;
| ^
ソースコード
#include <bits/stdc++.h>
using namespace std;
const int MM = 998244353;
long modpow(long a, long b, long mod) {
if (b == 0) {
return 1;
}
if ((b & 1) == 0) {
return modpow((a * a) % mod, b >> 1, mod);
}
return (a * modpow(a, b - 1, mod)) % mod;
}
int main() {
int N; cin >> N;
vector<int> A(N+1);
for (int i=0; i<N; i++) cin >> A[i];
vector<long> two(N+1);
two[0] = 1;
for (int i=1; i<N; i++) {
two[i] = 2*two[i-1] % MM;
}
vector<vector<long>> I(N+5, vector<long>(3));
I[0][2] = modpow(6, MM-2, MM); I[0][0] = 0; I[0][1] = 0;
I[1][0] = 1; I[1][1] = modpow(-2, MM-2, MM)+MM; I[1][2] = 0;
for (int i=1; i<(N+1)/2; i++) {
I[2*i+1][0] = (2*i*I[2*i-1][0] % MM) * modpow(2*i+1, MM-2, MM) % MM;
I[2*i+1][1] = ((2*i*I[2*i-1][1] % MM) * modpow(2*i+1, MM-2, MM) - modpow(two[2*i+1], MM-2, MM)) % MM;
if (I[2*i+1][1] < 0) I[2*i+1][1] += MM;
I[2*i+1][2] = (2*i*I[2*i-1][2] % MM) * modpow(2*i+1, MM-2, MM) % MM;
I[2*i][0] = ((2*i-1)*I[2*i-2][0] % MM) * modpow(2*i, MM-2, MM) % MM;
I[2*i][1] = (((2*i-1)*I[2*i-2][1] % MM) * modpow(2*i, MM-2, MM) - modpow(two[2*i], MM-2, MM)) % MM;
if (I[2*i][1] < 0) I[2*i][1] += MM;
I[2*i][2] = ((2*i-1)*I[2*i-2][2] % MM) * modpow(2*i, MM-2, MM) % MM;
}
long a, b, c = 0;
for (int i=0; i<N; i++) {
a = (a + (A[i]*two[i] % MM)*I[i][0] % MM) % MM;
b = (b + (A[i]*two[i] % MM)*I[i][1] % MM) % MM;
c = (c + (A[i]*two[i] % MM)*I[i][2] % MM) % MM;
}
cout << a << b << c << endl;
}
Re_menal2