結果
問題 | No.1540 級数おもちゃ |
ユーザー | Re_menal2 |
提出日時 | 2021-04-28 23:51:11 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,191 bytes |
コンパイル時間 | 1,884 ms |
コンパイル使用メモリ | 173,852 KB |
実行使用メモリ | 10,172 KB |
最終ジャッジ日時 | 2024-11-22 04:26:18 |
合計ジャッジ時間 | 7,108 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
コンパイルメッセージ
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:44: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:37:11: note: 'b' was declared here 37 | 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:44: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:37:8: note: 'a' was declared here 37 | 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+1, 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=2; i<N; i++) { I[i][0] = ((i-1)*I[i-1][0] % MM) * modpow(i, MM-2, MM) % MM; I[i][1] = (((i-1)*I[i-1][1] % MM) * modpow(i, MM-2, MM) % MM - modpow(two[i], MM-2, MM)) % MM; if (I[i][1] < 0) I[i][1] += MM; I[i][2] = ((i-1)*I[i-1][2] % MM) * modpow(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; }