結果
問題 |
No.40 多項式の割り算
|
ユーザー |
|
提出日時 | 2016-03-14 19:22:53 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 3 ms / 5,000 ms |
コード長 | 719 bytes |
コンパイル時間 | 549 ms |
コンパイル使用メモリ | 60,384 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-01 05:20:17 |
合計ジャッジ時間 | 1,602 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 32 |
ソースコード
#include <iostream> #include <vector> int main() { std::ios::sync_with_stdio(false); std::cin.tie(0); int d; std::vector<int> a; int result_rank = 0; std::cin >> d; for (int i = 0; i <= d; ++i) { int tmp; std::cin >> tmp; a.push_back(tmp); } if (d <= 2) { result_rank = d; std::cout << d << "\n"; } else { for (auto rit = a.rbegin(); rit != a.rend() - 3; ++rit) { *(rit + 2) += (*rit); *rit = 0; } for (int i = 2; i > 0; --i) { if (a[i] != 0) { result_rank = i; std::cout << i << "\n"; break; } } if (result_rank == 0) { std::cout << 0 << "\n"; } } for (int i = 0; i <= result_rank; ++i) { std::cout << a[i] << " "; } std::cout << "\n"; return 0; }