結果
| 問題 | 
                            No.1540 級数おもちゃ
                             | 
                    
| コンテスト | |
| ユーザー | 
                             Re_menal2
                         | 
                    
| 提出日時 | 2021-04-28 23:51:11 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.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 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| 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: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;
}
            
            
            
        
            
Re_menal2