結果

問題 No.1624 三角形の反射
ユーザー 夜
提出日時 2021-08-05 01:29:50
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,274 bytes
コンパイル時間 759 ms
コンパイル使用メモリ 90,780 KB
実行使用メモリ 8,696 KB
最終ジャッジ日時 2023-10-14 21:27:23
合計ジャッジ時間 5,699 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
	long double a;
	cin >> a;
	if (a > 1) {
		cout << "B ";
	}
	else if (a < 1) {
		cout << "C ";
	}
	else {
		cout << "A 1" << endl;
		return 0;
	}
	for (long double i = 1;; i++) {
		if (a * i == floor(a * i)) {
			int ans = (a + 1) * i - 2;
			for (long double j = 0; j <= a * i; j++) {
				for (long double k = 0; k <= i; k++) {
					long double x1 = 0, y1 = 0;
					long double x2 = a * i, y2 = i;
					long double x3 = j, y3 = k;
					long double x4, y4;
					if (int(floor(j + k)) % 2 == 0) {
						 x4 = j + 1, y4 = k - 1;
					}
					else {
						 x4 = j + 1, y4 = k + 1;
					}
					long double s = (x1 - x2) * (y3 - y1) + (y1 - y2) * (x1 - x3);
					long double t = (x1 - x2) * (y4 - y1) + (y1 - y2) * (x1 - x4);
					long double s1 = (x3 - x4) * (y1 - y3) + (y3 - y4) * (x3 - x1);
					long double t1 = (x3 - x4) * (y2 - y3) + (y3 - y4) * (x3 - x2);
					if (s * t < 0 && s1 * t1 < 0) {
						ans++;
					}
				}
			}
			cout << ans << endl;
			return 0;
		}
	}
}

0