結果

問題 No.132 点と平面との距離
ユーザー gigurururugigurururu
提出日時 2015-01-22 14:56:25
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 378 ms / 5,000 ms
コード長 1,244 bytes
コンパイル時間 4,355 ms
コンパイル使用メモリ 106,304 KB
実行使用メモリ 27,904 KB
最終ジャッジ日時 2023-09-05 03:35:39
合計ジャッジ時間 3,878 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
27,796 KB
testcase_01 AC 162 ms
27,788 KB
testcase_02 AC 378 ms
27,904 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections.Generic;
using System.Linq;

namespace yukicoder
{
	class Vector3{
		public double x,y,z;
		public Vector3(double _x,double _y,double _z){ x=_x;y=_y;z=_z; }
		public Vector3():this(0,0,0){}
		public Vector3(double[] a):this(a[0],a[1],a[2]){}
		public static Vector3 operator-(Vector3 s,Vector3 o) { return new Vector3(s.x-o.x,s.y-o.y,s.z-o.z); }
		public Vector3 cross_product(Vector3 o) { return new Vector3(y*o.z-z*o.y,z*o.x-x*o.z,x*o.y-y*o.x); }
		public double inner_product(Vector3 o) { return x*o.x+y*o.y+z*o.z; }
		public double norm() { return Math.Sqrt(x*x+y*y+z*z); }
		
	}
	class Program
	{
		public static void Main(string[] args)
		{
			int n;
			Vector3 P;
			Vector3[] l;
			double sum;
			n = int.Parse(Console.ReadLine());
			P = new Vector3(Console.ReadLine().Split(' ').Select(x=>double.Parse(x)).ToArray());
			l = new Vector3[300];
			for(int i=0;i<n;i++){
				l[i] = (new Vector3(Console.ReadLine().Split(' ').Select(x=>double.Parse(x)).ToArray()))-P;
			}
			sum=0;
			for(int i=0;i<n;i++)for(int j=i+1;j<n;j++)for(int k=j+1;k<n;k++){
				Vector3 t = (l[j]-l[i]).cross_product(l[k]-l[i]);
				sum += Math.Abs(l[i].inner_product(t))/t.norm();
			}
			Console.WriteLine(sum);
		}
	}
}
0