NC51068. Random Point in Triangle
描述
输入描述
The input consists of several test cases and is terminated by end-of-file.
Each test case contains six integers .
*
* There are at most test cases.
输出描述
For each test case, print an integer which denotes the result.
示例1
输入:
0 0 1 1 2 2 0 0 0 0 1 1 0 0 0 0 0 0
输出:
0 0 0
C++(clang++11) 解法, 执行用时: 357ms, 内存消耗: 2168K, 提交时间: 2020-10-24 13:56:43
#include<bits/stdc++.h> using namespace std; #define ll long long ll x,y,a,b,p,q; int main(){ while(cin>>x>>y>>a>>b>>p>>q){ cout<<abs((a-x)*(q-y)-(p-x)*(b-y))*11<<endl; } return 0; }
Python(2.7.3) 解法, 执行用时: 868ms, 内存消耗: 10232K, 提交时间: 2019-07-19 22:55:23
import math while True: try: x1,y1,x2,y2,x3,y3=map(int,raw_input().split()) s=11*abs((x1-x3)*(y2-y3)-(y1-y3)*(x2-x3)) print(int(s)) except: break
Ruby(2.4.2) 解法, 执行用时: 576ms, 内存消耗: 6496K, 提交时间: 2019-07-18 13:43:10
until STDIN.eof? t = gets.split.map(&:to_i) answer = (t[2] - t[0])*(t[5] - t[1]) - (t[3] - t[1])*(t[4] - t[0]) puts answer.abs * 11 end
Python3(3.5.2) 解法, 执行用时: 623ms, 内存消耗: 12636K, 提交时间: 2019-07-20 09:36:53
import sys for s in sys.stdin: x1,y1,x2,y2,x3,y3=map(int,s.split()) print(abs((x2-x1)*(y3-y1)-(x3-x1)*(y2-y1))*11)