日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

【数学】Hunter’s Apprentice

發布時間:2025/3/8 编程问答 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 【数学】Hunter’s Apprentice 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

題目描述

When you were five years old, you watched in horror as a spiked devil murdered your parents. You would?have died too, except you were saved by Rose, a passing demon hunter. She ended up adopting you and?training you as her apprentice.
Rose’s current quarry is a clock devil which has been wreaking havoc on the otherwise quiet and unassuming?town of Innsmouth. It comes out each night to damage goods, deface signs, and kill anyone foolish enough?to wander around too late. The clock devil has offed the last demon hunter after it; due to its time-warping?powers, it is incredibly agile and fares well in straight-up fights.
The two of you have spent weeks searching through dusty tomes for a way to defeat this evil. Eventually, you?stumbled upon a relevant passage. It detailed how a priest managed to ensnare a clock devil by constructing?a trap from silver, lavender, pewter, and clockwork. The finished trap contained several pieces, which must?be placed one-by-one in the shape of a particular polygon, in counter-clockwise order. The book stated that?the counter-clockwise order was important to counter the clock devil’s ability to speed its own time up, and?that a clockwise order would only serve to enhance its speed.
It was your responsibility to build and deploy the trap, while Rose prepared for the ensuing fight. You?carefully reconstruct each piece as well as you can from the book. Unfortunately, things did not go as?planned that night. Before you can finish preparing the trap, the clock devil finds the two of you. Rose tries?to fight the devil, but is losing quickly. However, she is buying you the time to finish the trap. You quickly?walk around them in the shape of the polygon, placing each piece in the correct position. You hurriedly?activate the trap as Rose is knocked out. Just then, you remember the book’s warning. What should you?do next?

?

輸入

The first line of input contains a single integer T (1 ≤ T ≤ 100), the number of test cases. The first line of?each test case contains a single integer n (3 ≤ n ≤ 20), the number of pieces in the trap. Each of the next?n lines contains two integers xi and yi (|xi |, |yi | ≤ 100), denoting the x and y coordinates of where the ith?piece was placed. It is guaranteed that the polygon is simple; edges only intersect at vertices, exactly two?edges meet at each vertex, and all vertices are distinct.

?

輸出

For each test case, output a single line containing either fight if the trap was made correctly or run if the?trap was made incorrectly.

?

樣例輸入

復制樣例數據

2 3 0 0 1 0 0 1 3 0 0 0 1 1 0

樣例輸出

fight run

?

提示

In the first case, you went around the polygon in the correct direction, so it is safe to fight the clock devil
and try to save Rose.
In the second case, you messed up, and it is time to start running. Sorry Rose!

?

題目大意:

先輸入一個整數t,下面有t組測試,對于每組測試,先輸入一個整數n,然后按順序輸入n個點的坐標,這些點能圍成一個多邊形,最后根據若是按順時針轉,則輸出run,否則輸出fight。

解題思路:

這題是要求多邊形的順逆時針的問題,其實就是通過一個模板直接判斷,知道這個模板的話非常簡單,此題可以通過Green公式求解多邊形順逆時針來解。

代碼:

#include <cstdio> #include <iostream> #include <algorithm> #include <cmath> #include <cstdlib> #include <cstring> #include <map> #include <stack> #include <queue> #include <vector> #include <bitset> #include <set> #include <utility> #include <sstream> #include <iomanip> using namespace std; typedef long long ll; typedef unsigned long long ull; #define inf 0x3f3f3f3f #define rep(i,l,r) for(int i=l;i<=r;i++) #define lep(i,l,r) for(int i=l;i>=r;i--) #define ms(arr) memset(arr,0,sizeof(arr)) //priority_queue<int,vector<int> ,greater<int> >q; const int maxn = (int)1e5 + 5; const ll mod = 1e9+7; struct node {double x,y; }arr[100]; int main() {#ifndef ONLINE_JUDGEfreopen("in.txt", "r", stdin);#endif//freopen("out.txt", "w", stdout);ios::sync_with_stdio(0),cin.tie(0);int t;cin>>t;while(t--) {int n;cin>>n;rep(i,1,n) cin>>arr[i].x>>arr[i].y;double nape=0;rep(i,1,n-1) {nape+=(-0.5)*(arr[i+1].x-arr[i].x)*(arr[i+1].y+arr[i].y); //Green公式}nape+=(-0.5)*(arr[1].x-arr[n].x)*(arr[1].y+arr[n].y);if(nape<0) cout<<"run"<<endl;else cout<<"fight"<<endl;}return 0; }

?

總結

以上是生活随笔為你收集整理的【数学】Hunter’s Apprentice的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。