結果
問題 |
No.3225 2×2行列相似判定 〜easy〜
|
ユーザー |
|
提出日時 | 2025-08-08 23:00:04 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 125 ms / 2,000 ms |
コード長 | 1,379 bytes |
コンパイル時間 | 1,826 ms |
コンパイル使用メモリ | 196,148 KB |
実行使用メモリ | 7,716 KB |
最終ジャッジ日時 | 2025-08-08 23:00:09 |
合計ジャッジ時間 | 4,366 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 33 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; const ll mod = 67; const int N = 200005; const int INF = 0x3f3f3f3f; int inv(int a) { a = (a % mod + mod) % mod; if (a == 0) return -1; for (int x = 1; x < mod; x++) { if ((a * x % mod + mod) % mod == 1) return x; } return -1; } int cal(int x) { return (x % mod + mod) % mod; } int main() { int A[2][2], B[2][2]; for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) cin >> A[i][j]; } for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) cin >> B[i][j]; } for (int a = 0; a < mod; a++) { for (int b = 0; b < mod; b++) { for (int c = 0; c < mod; c++) { for (int d = 0; d < mod; d++) { if (cal(a * d - b * c) == 0) continue; if (cal(a * A[0][0] + b * A[1][0]) != cal(B[0][0] * a + B[0][1] * c)) continue; if (cal(a * A[0][1] + b * A[1][1]) != cal(B[0][0] * b + B[0][1] * d)) continue; if (cal(c * A[0][0] + d * A[1][0]) != cal(B[1][0] * a + B[1][1] * c)) continue; if (cal(c * A[0][1] + d * A[1][1]) != cal(B[1][0] * b + B[1][1] * d)) continue; cout << "Yes\n"; return 0; } } } } cout << "No\n"; return 0; }