結果
問題 |
No.554 recurrence formula
|
ユーザー |
![]() |
提出日時 | 2017-08-11 22:40:52 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 551 bytes |
コンパイル時間 | 774 ms |
コンパイル使用メモリ | 75,836 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-12 21:22:20 |
合計ジャッジ時間 | 1,444 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 9 WA * 12 |
コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/iostream:39, from main.cpp:6: In member function 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char; _Traits = std::char_traits<char>]', inlined from 'int main()' at main.cpp:31:11: /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/ostream:202:25: warning: 'ans' may be used uninitialized [-Wmaybe-uninitialized] 202 | { return _M_insert(__n); } | ~~~~~~~~~^~~~~ main.cpp: In function 'int main()': main.cpp:17:17: note: 'ans' was declared here 17 | long long int ans; | ^~~
ソースコード
#include <cstdio> #include <cstring> #include <cmath> #include <queue> #include <algorithm> #include <iostream> using namespace std; long long int N = 1000000009; int main() { long long int n; cin >> n; long long int sum1 = 1; long long int sum0 = 0; int count = 2; long long int ans; while(count <= n){ if(count%2==0){ ans = ( count * sum1 ) % N ; sum0 = (sum0 + ans ) % N; } else{ ans = ( count * sum0 ) % N ; sum1 = (sum1 + ans) % N; } count++; } cout << ans << endl; return 0; }