Crane (POJ 2991)】的更多相关文章

POJ - 2991 思路: 向量旋转: 代码: #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; #define maxn 400005 const double pi=acos(-1.0); struct TreeNodeType { int l,r,R,mid,…
//线段树 延迟标签 // #include <bits/stdc++.h> using namespace std; const int maxn=1e4+5; double x[maxn*4]; double y[maxn*4]; int degreen[maxn]; int d[maxn*4];//延迟标签 void rotate(int i,int num) { double ang=(1.0*num)/180*acos(-1); double newx=x[i]*cos(ang)-y…
POJ 2991 Crane 题目链接 题意:给定一个垂直的挖掘机臂.有n段,如今每次操作能够旋转一个位置,把[s, s + 1]专程a度,每次旋转后要输出第n个位置的坐标 思路:线段树.把每一段当成一个向量,这样每一段的坐标就等于前几段的坐标和,然后每次旋转的时候,相当于把当前到最后位置所有加上一个角度,这样就须要区间改动了.然后每次还须要查询s,和s + 1当前的角度,所以须要单点查询,这样用线段树去维护就可以 代码: #include <cstdio> #include <cstr…
Description ACM has bought a new crane (crane -- jeřáb) . The crane consists of n segments of various lengths, connected by flexible joints. The end of the i-th segment is joined to the beginning of the i + 1-th one, for 1 ≤ i < n. The beginning of t…
Crane Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 7687   Accepted: 2075   Special Judge Description ACM has bought a new crane (crane -- jeřáb) . The crane consists of n segments of various lengths, connected by flexible joints. The…
题目链接 Description ACM has bought a new crane (crane -- jeřáb) . The crane consists of n segments of various lengths, connected by flexible joints. The end of the i-th segment is joined to the beginning of the i + 1-th one, for 1 ≤ i < n. The beginning…
Description ACM has bought a new crane (crane -- jeřáb) . The crane consists of n segments of various lengths, connected by flexible joints. The end of the i-th segment is joined to the beginning of the i + 1-th one, for 1 ≤ i < n. The beginning of t…
题意: 把手臂都各自看成一个向量,则机械手的位置正好是手臂向量之和.旋转某个关节,其实就是把关节到机械手之间的手臂向量统统旋转. 由于手臂很多,要每个向量做相同的旋转操作很费时间.这时就可以想到用线段树的优势正是可以快速地成段更新.和一般的成段更新题目没什么差别,只是通常成段替换.或者成段增加.这时候要做的是,对向量成段得做旋转变换.只要利用旋转变化矩阵即可. 要注意,从第 s 节手臂开始到机械手要旋转的角度,和第 s - 1 节手臂的角度有关.因此我们还要记录每个手臂的角度,并且去Query得…
题意: 起重机的机械臂, 由n段组成, 对某一些连接点进行旋转, 询问每次操作后的末端坐标. 思路: 由于旋转会影响到该点之后所有线段的角度, 因此容易想到用线段树记录角度, 成段更新. (但是不是每一次操作都要询问一次么? 那么懒惰标记还有用么? 如果使用懒惰标记, 将一些线段视为整体, 那么这些线段岂不是又要用一个线段树记录一段区间的总长? 树状数组亦可...) 将向量视为数量整体加和, 融入到线段树的操作中, 就可以避免角度和坐标分离的麻烦事.. 旋转角度与坐标的关系: 根据位移向量绕原点…
线段树+计算几何,区间更新,区间求和,向量旋转. /* *********************************************** Author :Zhou Zhentao Email :774388357@qq.com Created Time :2015/11/27 9:58:30 File Name :main.cpp ************************************************ */ #include <stdio.h> #inc…
地址 http://poj.org/problem?id=2991 题解 本来以为这是一个简单的线段树模板 不料始终不太明白线段树如何记录转动角度后的各个线段端的XY值 学习了网络上的一些博客题解 感觉似是而非 谈到复数 角度 向量等,有点不太好理解 现在这里将自己的理解记录如下 如图 1 预备知识 使用线段树记录的内容如下  指示某段线段的组合 以第一条线段为垂直 最后的线段的端点的X Y值 途中1~2 线段 和3~5线段 就是线段树节点1~5的子节点 那么线段树节点1~5 就记录1~5结合后…
我们只要把这些向量求和,最终所指的位置就是终点,因此我们只要维护好向量的区间和就可以了.对于第二个问题,我们可以用一个数组degree[i]表示第i个向量和第i-1一个向量当前的夹角,这样就有了当前的状态,每次读入操作后就会方便的得到相当于进行旋转多少角度的操作了,然后再更新一下degree[i]即可.并且我们每读入一个操作只会影响一个degree[]的值,不会影响到其他的degree[]. 总而言之,我们要把每个线段看成一个向量,并维护这些向量的区间和,同时要实现对区间中每个元素都加上一个值这…
#include<stdio.h> #include<math.h> #include<string.h> #include<stdlib.h> #define N (10010<<2) #define maxn 10000 #define lson l,m,rt<<1 #define rson m+1,r,rt<<1|1 #define pi acos(-1.0) int ang[N]; ]; void Rotate(i…
F - Heavy Transportation Time Limit:3000MS     Memory Limit:30000KB     64bit IO Format:%I64d & %I64u Submit Status Practice POJ 1797 Description Background Hugo Heavy is happy. After the breakdown of the Cargolifter project he can now expand busines…
题目链接:http://poj.org/problem?id=1797 Heavy Transportation Time Limit: 3000MS   Memory Limit: 30000K Total Submissions: 30840   Accepted: 8191 Description Background Hugo Heavy is happy. After the breakdown of the Cargolifter project he can now expand…
题目链接:http://poj.org/problem?id=1797 Description Background Hugo Heavy is happy. After the breakdown of the Cargolifter project he can now expand business. But he needs a clever man who tells him whether there really is a way from the place his custom…
poj 1797 Heavy Transportation Description Background Hugo Heavy is happy. After the breakdown of the Cargolifter project he can now expand business. But he needs a clever man who tells him whether there really is a way from the place his customer has…
题目链接: http://poj.org/problem?id=1797 Background Hugo Heavy is happy. After the breakdown of the Cargolifter project he can now expand business. But he needs a clever man who tells him whether there really is a way from the place his customer has buil…
POJ 1797 Heavy Transportation / SCU 1819 Heavy Transportation (图论,最短路径) Description Background Hugo Heavy is happy. After the breakdown of the Cargolifter project he can now expand business. But he needs a clever man who tells him whether there reall…
Heavy Transportation Time Limit:3000MS     Memory Limit:30000KB     64bit IO Format:%I64d & %I64u Submit Status Practice POJ 1797 Description Background Hugo Heavy is happy. After the breakdown of the Cargolifter project he can now expand business. B…
原题链接:http://poj.org/problem?id=1797 Heavy Transportation Time Limit: 3000MS   Memory Limit: 30000K Total Submissions: 24576   Accepted: 6510 Description Background Hugo Heavy is happy. After the breakdown of the Cargolifter project he can now expand…
题目链接:POJ 1797 Description Background Hugo Heavy is happy. After the breakdown of the Cargolifter project he can now expand business. But he needs a clever man who tells him whether there really is a way from the place his customer has build his giant…
题目链接:POJ 1797 Description Background Hugo Heavy is happy. After the breakdown of the Cargolifter project he can now expand business. But he needs a clever man who tells him whether there really is a way from the place his customer has build his giant…
Halloween treats Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 7644   Accepted: 2798   Special Judge Description Every year there is the same problem at Halloween: Each neighbour is only willing to give a certain total number of sweets…
Find a multiple Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7192   Accepted: 3138   Special Judge Description The input contains N natural (i.e. positive integer) numbers ( N <= 10000 ). Each of that numbers is not greater than 15000…
The Pilots Brothers' refrigerator Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 22286   Accepted: 8603   Special Judge Description The game “The Pilots Brothers: following the stripy elephant” has a quest where a player needs to open a…
Flip Game Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 37427   Accepted: 16288 Description Flip game is played on a rectangular 4x4 field with two-sided pieces placed on each of its 16 squares. One side of each piece is white and the…
Corn Fields Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 9806   Accepted: 5185 Description Farmer John has purchased a lush new rectangular pasture composed of M by N (1 ≤ M ≤ 12; 1 ≤ N ≤ 12) square parcels. He wants to grow some yumm…
Sum of Consecutive Prime Numbers Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 20050   Accepted: 10989 Description Some positive integers can be represented by a sum of one or more consecutive prime numbers. How many such representatio…
Tree Recovery Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 11939   Accepted: 7493 Description Little Valentine liked playing with binary trees very much. Her favorite game was constructing randomly looking binary trees with capital le…