結果
問題 | No.55 正方形を描くだけの簡単なお仕事です。 |
ユーザー |
![]() |
提出日時 | 2014-11-03 02:08:40 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 1 ms / 5,000 ms |
コード長 | 3,179 bytes |
コンパイル時間 | 123 ms |
コンパイル使用メモリ | 23,552 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-14 13:42:17 |
合計ジャッジ時間 | 885 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 21 |
コンパイルメッセージ
main.cpp: In function ‘void yukicoder55()’: main.cpp:23:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 23 | scanf("%lf %lf %lf %lf %lf %lf", &inPoint[0].X, &inPoint[0].Y, &inPoint[1].X, &inPoint[1].Y, &inPoint[2].X, &inPoint[2].Y); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
/*yukicoder No.55(Ver3)作成者:ヒロソフ*/#include <stdio.h>struct Point {double X;double Y;};void yukicoder55(void);int main(void) {yukicoder55();return 0;}void yukicoder55(void) {Point inPoint[3];bool bPossible;scanf("%lf %lf %lf %lf %lf %lf", &inPoint[0].X, &inPoint[0].Y, &inPoint[1].X, &inPoint[1].Y, &inPoint[2].X, &inPoint[2].Y);//1点目を中点と仮定するdouble Length[2] , hypLength;Point pt_Center;Length[0] = (inPoint[1].X - inPoint[0].X) * (inPoint[1].X - inPoint[0].X) + (inPoint[1].Y - inPoint[0].Y) * (inPoint[1].Y - inPoint[0].Y);Length[1] = (inPoint[2].X - inPoint[0].X) * (inPoint[2].X - inPoint[0].X) + (inPoint[2].Y - inPoint[0].Y) * (inPoint[2].Y - inPoint[0].Y);hypLength = (inPoint[2].X - inPoint[1].X) * (inPoint[2].X - inPoint[1].X) + (inPoint[2].Y - inPoint[1].Y) * (inPoint[2].Y - inPoint[1].Y);bPossible = (Length[0] == Length[1]);bPossible &= ((Length[0] + Length[1]) == hypLength);if (bPossible) {pt_Center.X = (inPoint[1].X + inPoint[2].X) / 2;pt_Center.Y = (inPoint[1].Y + inPoint[2].Y) / 2;Point diff;diff.X = pt_Center.X - inPoint[0].X;diff.Y = pt_Center.Y - inPoint[0].Y;printf("%d %d\n", (int)(inPoint[0].X + 2 * diff.X), (int)(inPoint[0].Y + 2 * diff.Y));} else {//2点目を中心と仮定するLength[0] = (inPoint[0].X - inPoint[1].X) * (inPoint[0].X - inPoint[1].X) + (inPoint[0].Y - inPoint[1].Y) * (inPoint[0].Y - inPoint[1].Y);Length[1] = (inPoint[2].X - inPoint[1].X) * (inPoint[2].X - inPoint[1].X) + (inPoint[2].Y - inPoint[1].Y) * (inPoint[2].Y - inPoint[1].Y);hypLength = (inPoint[2].X - inPoint[0].X) * (inPoint[2].X - inPoint[0].X) + (inPoint[2].Y - inPoint[0].Y) * (inPoint[2].Y - inPoint[0].Y);bPossible = (Length[0] == Length[1]);bPossible &= ((Length[0] + Length[1]) == hypLength);if (bPossible) {pt_Center.X = (inPoint[0].X + inPoint[2].X) / 2;pt_Center.Y = (inPoint[0].Y + inPoint[2].Y) / 2;Point diff;diff.X = pt_Center.X - inPoint[1].X;diff.Y = pt_Center.Y - inPoint[1].Y;printf("%d %d\n", (int)(inPoint[1].X + 2 * diff.X), (int)(inPoint[1].Y + 2 * diff.Y));} else {//3点目を中心と仮定するLength[0] = (inPoint[0].X - inPoint[2].X) * (inPoint[0].X - inPoint[2].X) + (inPoint[0].Y - inPoint[2].Y) * (inPoint[0].Y - inPoint[2].Y);Length[1] = (inPoint[1].X - inPoint[2].X) * (inPoint[1].X - inPoint[2].X) + (inPoint[1].Y - inPoint[2].Y) * (inPoint[1].Y - inPoint[2].Y);hypLength = (inPoint[1].X - inPoint[0].X) * (inPoint[1].X - inPoint[0].X) + (inPoint[1].Y - inPoint[0].Y) * (inPoint[1].Y - inPoint[0].Y);bPossible = (Length[0] == Length[1]);bPossible &= ((Length[0] + Length[1]) == hypLength);if (bPossible) {pt_Center.X = (inPoint[0].X + inPoint[1].X) / 2;pt_Center.Y = (inPoint[0].Y + inPoint[1].Y) / 2;Point diff;diff.X = pt_Center.X - inPoint[2].X;diff.Y = pt_Center.Y - inPoint[2].Y;printf("%d %d\n", (int)(inPoint[2].X + 2 * diff.X), (int)(inPoint[2].Y + 2 * diff.Y));} else {printf("-1\n");}}}}