結果
問題 |
No.3003 多項式の割り算 〜hard〜
|
ユーザー |
|
提出日時 | 2025-02-04 16:55:08 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 714 bytes |
コンパイル時間 | 2,901 ms |
コンパイル使用メモリ | 203,260 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2025-02-04 16:55:13 |
合計ジャッジ時間 | 4,654 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 20 |
ソースコード
#include<bits/stdc++.h> using namespace std; using ll = long long; using V = vector<ll>; using M = vector<V>; M mult(M a,M b){ M res(a.size(),V(b[0].size(),0)); for(int i=0;i<a.size();++i){ for(int j=0;j<b[0].size();++j){ for(int k=0;k<a[0].size();++k){ res[i][j] += a[i][k] * b[k][j]; } } } return res; } int main(){ ll a; ll b; cin >> a >> b; vector<int> xs(3,0); M state(3,V(1,0)); state[2][0] = a; M r(3,V(3,0)); M l(3,V(3,0)); r[0][1] = 1; r[1][2] = 1; l[1][1] = 1; l[2][2] = 1; l[1][0] = -1; l[2][0] = -1; M m = mult(l,r); while(b > 0){ if(b % 2 == 1){ state = mult(m, state); } m = mult(m,m); b /= 2; } cout << state[1][0] << " " << state[2][0] << endl; }