結果

問題 No.3054 ほぼ直角二等辺三角形
ユーザー ats5515ats5515
提出日時 2019-04-01 22:32:42
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,427 bytes
コンパイル時間 732 ms
コンパイル使用メモリ 76,252 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-18 01:43:59
合計ジャッジ時間 1,996 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
int mat[2][2] = { {3,4},{2,3} };
void matmul(int A[2][2],int B[2][2]) {
	int X[2][2];
	int Y[2][2];
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < 2; j++) {
			X[i][j] = A[i][j];
			Y[i][j] = B[i][j];
		}
	}
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < 2; j++) {
			A[i][j] = 0;
			for (int k = 0; k < 2; k++) {
				A[i][j] += X[i][k] * Y[k][j];
			}
		}
	}

}
void matpow(int A[2][2], int p) {
	if (p == 1)return;
	int X[2][2];

	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < 2; j++) {
			X[i][j] = A[i][j];
		}
	}
	matpow(A, p / 2);

	matmul(A, A);
	
	if (p % 2 == 1) {
		matmul(A, X);
	}


}
int keta(int a) {
	int res = 0;
	while (a > 0) {
		res++;
		a /= 10;
	}
	return res;
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N; cin >> N;

	int T[2][2];

	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < 2; j++) {
			T[i][j] = mat[i][j];
		}
	}
	int k = 1;
	while (true) {
		
		k++;
		//if (k > 20)break;

		//cerr << T[1][0] + T[1][1] << endl;
		if (keta(T[1][0] + T[1][1]) == N) {
			int a = (T[0][0] + T[0][1] - 1) / 2;
			int c = T[1][0] + T[1][1];
			cout << a << " " << a + 1 << " " << c << endl;
			break;
		}
		matmul(T, mat);
	}
}
0