結果
問題 | No.3002 多項式の割り算 〜easy〜 |
ユーザー |
|
提出日時 | 2025-02-09 19:58:36 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 691 bytes |
コンパイル時間 | 1,722 ms |
コンパイル使用メモリ | 196,252 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2025-02-09 19:58:40 |
合計ジャッジ時間 | 3,216 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 21 RE * 1 |
ソースコード
#include <bits/stdc++.h>using namespace std;template<class T> std::vector<T> zako_division(std::vector<T> &lhs, const std::vector<T> &rhs){std::vector<T> res(lhs.size() - rhs.size() + 1);int stop = rhs.size() - 1;for(int i = lhs.size() - 1; i >= stop; i--){res[i - stop] = lhs[i] / rhs.back();T cur = res[i - stop];for(int j = 0; j < rhs.size(); j++){lhs[i - j] -= rhs.rbegin()[j] * cur;}}return res;}int main(){ios::sync_with_stdio(false);cin.tie(0);int a, b;cin >> a >> b;vector<int> A(b + 1), B(3, 1);A[b] = a;zako_division(A, B);cout << A[1] << " " << A[0] << '\n';}