結果
| 問題 | 
                            No.3224 2×2行列入門
                             | 
                    
| コンテスト | |
| ユーザー | 
                             tnakao0123
                         | 
                    
| 提出日時 | 2025-08-10 17:09:18 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 1 ms / 2,000 ms | 
| コード長 | 1,098 bytes | 
| コンパイル時間 | 390 ms | 
| コンパイル使用メモリ | 42,480 KB | 
| 実行使用メモリ | 7,716 KB | 
| 最終ジャッジ日時 | 2025-08-10 17:09:19 | 
| 合計ジャッジ時間 | 1,683 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 23 | 
コンパイルメッセージ
main.cpp: In static member function ‘static Mat2<T> Mat2<T>::read() [with T = long long int]’:
main.cpp:26:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   26 |     scanf("%d%d%d%d", &w, &x, &y, &z);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
            
            ソースコード
/* -*- coding: utf-8 -*-
 *
 * 3224.cc:  No.3224 2テ・陦悟・蜈・髢 - yukicoder
 */
#include<cstdio>
#include<algorithm>
using namespace std;
/* constant */
/* typedef */
using ll = long long;
template <typename T>
struct Mat2 {
  T a, b, c, d;
  Mat2(): a(), b(), c(), d() {}
  Mat2(T _a, T _b, T _c, T _d): a(_a), b(_b), c(_c), d(_d) {}
  static Mat2 unit() { return Mat2(1, 0, 0, 1); }
  static Mat2 read() {
    int w, x, y, z;
    scanf("%d%d%d%d", &w, &x, &y, &z);
    return Mat2(w, x, y, z);
  }
  Mat2 operator*(const Mat2 &e) const {
    return Mat2(a * e.a + b * e.c, a * e.b + b * e.d,
		c * e.a + d * e.c, c * e.b + d * e.d);
  }
  Mat2 operator^(int b) const {
    Mat2 p = Mat2::unit();
    Mat2 a = *this;
    while (b > 0) {
      if (b & 1) p = p * a;
      a = a * a;
      b >>= 1;
    }
    return p;
  }
};
using mat2 = Mat2<ll>;
/* global variables */
/* subroutines */
/* main */
int main() {
  mat2 ma = mat2::read();
  mat2 mb = mat2::read();
  mat2 mc = (ma * mb) ^ 2;
  printf("%lld %lld\n%lld %lld\n", mc.a, mc.b, mc.c, mc.d);
  
  return 0;
}
            
            
            
        
            
tnakao0123