結果
| 問題 |
No.40 多項式の割り算
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-03-14 19:19:22 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 777 bytes |
| コンパイル時間 | 646 ms |
| コンパイル使用メモリ | 60,200 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-01 05:20:15 |
| 合計ジャッジ時間 | 1,341 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 29 WA * 3 |
ソースコード
#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) {
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";
}
}
if (result_rank == 0 || d == 0) {
std::cout << 0 << " ";
}
else {
for (int i = 0; i <= result_rank; ++i) {
std::cout << a[i] << " ";
}
}
std::cout << "\n";
return 0;
}