The 2014 ACM-ICPC Asia Regional Anshan Online

【B】

Rotate

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)

Special Judge

【Problem Description】

Noting is more interesting than rotation!
Your little sister likes to rotate things. To put it easier to analyze, your sister makes n rotations. In the i-th time, she makes everything in the plane rotate counter-clockwisely around a point ai by a radian of pi.
Now she promises that the total effect of her rotations is a single rotation around a point A by radian P (this means the sum of pi is not a multiplier of 2π).
Of course, you should be able to figure out what is A and P :).

【Input】

The first line contains an integer T, denoting the number of the test cases.
For each test case, the first line contains an integer n denoting the number of the rotations. Then n lines follows, each containing 3 real numbers x, y and p, which means rotating around point (x, y) counter-clockwisely by a radian of p.
We promise that the sum of all p‘s is differed at least 0.1 from the nearest multiplier of 2π.
T<=100. 1<=n<=10. 0<=x, y<=100. 0<=p<=2π.

【Output】

For each test case, print 3 real numbers x, y, p, indicating that the overall rotation is around (x, y) counter-clockwisely by a radian of p. Note that you should print p where 0<=p<2π.
Your answer will be considered correct if and only if for x, y and p, the absolute error is no larger than 1e-5.

【Sample Input】

1

3

0 0 1

1 1 1

2 2 1

【Sample Output】

1.8088715944 0.1911284056 3.0000000000

【题意】

对于每一组测试数据,给出一系列旋转命令,每次将整个平面空间绕着某一点逆时针旋转某一个弧度。而所有这些操作的最终结果可以等效为绕着A点旋转P弧度,题目的要求即求出这个坐标点A和弧度P。

【分析】

当时看到这题解析几何,第一反应就是不想去管它了,因为手头没有趁手的模板可用,本来就数学不好,算起来太过耗时,还容易错,无奈水平有限,能做的题目不多,还是回来写这个了。

既然题目确定了所有这些操作都可以等效为一个,那我们也不需呀去管这个结论是怎么证明出来的了。基本的思想是用一条线段去指代这个平面,每次将线段的两端点都进行一次旋转操作,就相当于整条线段都旋转了,更进一步地就代表平面旋转了。之后分析原始坐标与结果坐标之间的关系即可得出等效结果。

一、原坐标与起始坐标相连的线段必然是以旋转中心为圆心的圆上的一条弦。则根据两个点的旋转结果,取线段中垂线算出交点即可求出圆心,即旋转中心;

二、然后就是旋转角度了,画个三角形余弦定理求解即可。

【注意】

最开始一直WA是忽略了一个问题就是P的范围是0~2Pi,三角形余弦定理计算出的结果肯定是小于Pi的,就是最后必须判断一下旋转角度是否超过了Pi,超了则最终的输出结果应该是2Pi-P。这里要用到判断两点是否在一条直线的同一边。

没有好的模板......下面的代码看着各种乱啊:

 1 /*
 2 ID:        Chen Fan
 3 PROG:    B1002
 4 LANG:    G++
 5 */
 6
 7 #include<iostream>
 8 #include<cstdio>
 9 #include<cmath>
10
11 #define Pi 3.141592657
12
13 typedef struct poi
14 {
15     double x,y;
16 } point;
17
18 using namespace std;
19
20 point rotate(point v,point p,double angle)
21 {
22     point ret=p;
23     v.x-=p.x,v.y-=p.y;
24     p.x=cos(angle);
25     p.y=sin(angle);
26     ret.x+=v.x*p.x-v.y*p.y;
27     ret.y+=v.x*p.y+v.y*p.x;
28     return ret;
29 }
30
31 int main()
32 {
33     int t;
34     scanf("%d",&t);
35     for (int tt=1;tt<=t;tt++)
36     {
37         int n;
38         scanf("%d",&n);
39         point p1={20.123,6.678},p2={3.414,10.123};
40         point p0={(p1.x+p2.x)/2,(p1.y+p2.y)/2};
41         for (int i=1;i<=n;i++)
42         {
43             point now;
44             double p;
45             scanf("%lf%lf%lf",&now.x,&now.y,&p);
46             p1=rotate(p1,now,p);
47             p2=rotate(p2,now,p);
48         }
49
50         point p10;
51         p10.x=(p1.x+20.123)/2;
52         p10.y=(p1.y+6.678)/2;
53         double k1=(p1.y-p10.y)/(p1.x-p10.x);
54         k1=-1/k1;
55         double b1=p10.y-k1*p10.x;
56
57         point p20;
58         p20.x=(p2.x+3.414)/2;
59         p20.y=(p2.y+10.123)/2;
60         double k2=(p2.y-p20.y)/(p2.x-p20.x);
61         k2=-1/k2;
62         double b2=p20.y-k2*p20.x;
63
64         double xx=(b2-b1)/(k1-k2);
65         double yy=k1*xx+b1;
66
67         double bb=(xx-3.414)*(xx-3.414)+(yy-10.123)*(yy-10.123);
68         double cc=(xx-p2.x)*(xx-p2.x)+(yy-p2.y)*(yy-p2.y);
69         double aa=(p2.x-3.414)*(p2.x-3.414)+(p2.y-10.123)*(p2.y-10.123);
70         double ct=(bb+cc-aa)/(2*sqrt(bb)*sqrt(cc));
71
72         point p3={2*xx-p0.x,2*yy-p0.y};
73         point p4={(p1.x+p2.x)/2,(p1.y+p2.y)/2};
74
75         double k3=(p3.y-p0.y)/(p3.x-p0.x);
76         double b3=p3.y-k3*p3.x;
77
78         point pp={xx,yy};
79         point p5=rotate(p0,pp,1);
80
81         if ((p4.x*k3+b3-p4.y)*(p5.x*k3+b3-p5.y)>0) printf("%.10lf %.10lf %.10lf\n",xx,yy,acos(ct));
82         else printf("%.10lf %.10lf %.10lf\n",xx,yy,2*Pi-acos(ct));
83     }
84
85     return 0;
86 }

【E】

Walk

Time Limit: 30000/15000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)

【Problem Description】

I used to think I could be anything, but now I know that I couldn‘t do anything. So I started traveling.
The nation looks like a connected bidirectional graph, and I am randomly walking on it. It means when I am at node i, I will travel to an adjacent node with the same probability in the next step. I will pick up the start node randomly (each node in the graph has the same probability.), and travel for d steps, noting that I may go through some nodes multiple times.
If I miss some sights at a node, it will make me unhappy. So I wonder for each node, what is the probability that my path doesn‘t contain it.

【Input】

The first line contains an integer T, denoting the number of the test cases.
For each test case, the first line contains 3 integers n, m and d, denoting the number of vertices, the number of edges and the number of steps respectively. Then m lines follows, each containing two integers a and b, denoting there is an edge between node a and node b.
T<=20, n<=50, n-1<=m<=n*(n-1)/2, 1<=d<=10000. There is no self-loops or multiple edges in the graph, and the graph is connected. The nodes are indexed from 1.

【Output】

For each test cases, output n lines, the i-th line containing the desired probability for the i-th node.
Your answer will be accepted if its absolute error doesn‘t exceed 1e-5.

【Sample Input】

2

5 10 100

1 2

2 3

3 4

4 5

1 5

2 4

3 5

2 5

1 4

1 3

10 10 10

1 2

2 3

3 4

4 5

5 6

6 7

7 8

8 9

9 10

4 9

【Sample Output】

0.0000000000

0.0000000000

0.0000000000

0.0000000000

0.0000000000

0.6993317967

0.5864284952

0.4440860821

0.2275896991

0.4294074591

0.4851048742

0.4896018842

0.4525044250

0.3406567483

0.6421630037

【题意】

随机随机随机...在一张无向图中,随机选定一个起点出发,之后的每一步都是等概率的。有一些点不能被到达,这里要求的就是每一个点不能被到达的概率。

【分析】

概率DP的题目做得太少了

【G】

Osu!

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)

Special Judge

【Problem Description】

Osu! is a famous music game that attracts a lot of people. In osu!, there is a performance scoring system, which evaluates your performance. Each song you have played will have a score. And the system will sort all you scores in descending order. After that, the i-th song scored ai will add 0.95^(i-1)*ai to your total score.
Now you are given the task to write a calculator for this system.

【Input】

The first line contains an integer T, denoting the number of the test cases.
For each test case, the first line contains an integer n, denoting the number of songs you have played. The second line contains n integers a1, a2, ..., an separated by a single space, denoting the score of each song.
T<=20, n<=50, 1<=ai<=500.

【Output】

For each test case, output one line for the answer.
Your answers will be considered correct if its absolute error is smaller than 1e-5.

【Sample Input】

1

2

530 478

【Sample Output】

984.1000000000

【分析】

水过了....

时间: 2024-10-16 18:48:44

The 2014 ACM-ICPC Asia Regional Anshan Online的相关文章

HDU 5000 2014 ACM/ICPC Asia Regional Anshan Online DP

Clone Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/65536K (Java/Other) Total Submission(s) : 8   Accepted Submission(s) : 5 Font: Times New Roman | Verdana | Georgia Font Size: ← → Problem Description After eating food from Chernobyl,

poj 5001 Walk &amp;&amp;2014 ACM/ICPC Asia Regional Anshan Online 1005(dp)

http://acm.hdu.edu.cn/showproblem.php?pid=5001 思路:dp计算出途径每个点的总概率,1-x即为所求解. dp题,先介绍下dp[i][j]为第j步走在第i个点的概率,那么dp[i][j]=dp[x1][j-1]+dp[x2][j-1]+...,x1,x2为i 的相邻节点.上一步在相邻节点这一步才能走到该点嘛. 每个点概率要一个一个的算,当算到第ii个点时(没打错,ii个点与代码对应),从起点推起,起点嘛,算是第0步吧,每个点被选中几率1.0/n,直接计

2014 ACM/ICPC Asia Regional Anshan Online

已经确定了的... B Rotate 1 /* 2 ID:esxgx1 3 LANG:C++ 4 PROG:B 5 */ 6 #include <cmath> 7 #include <cstdio> 8 #include <cstring> 9 #include <iostream> 10 #include <algorithm> 11 using namespace std; 12 13 struct p { 14 double x,y; 15

HDU 5000 Clone 规律+dp 2014 ACM/ICPC Asia Regional Anshan Online

每只羊有n个属性 下面n个数字表示每个属性的值范围为[ 0, T[i] ] 对于羊圈里的a羊和b羊,若a羊的每个属性都>=b羊,则a羊会杀死b羊. 问羊圈里最多存活多少只羊. 规律1:sum相同的羊不会互相杀死. 因为若2个羊的属性都相同,a羊某个属性要增加1,则a羊另一个属性要减少1,这样ab一定能共存. 规律2: sum不同的羊不会重合. 我们设a羊sum = x,b羊sum = y,若a,b羊能共存,但不会把ab同时放到羊圈里. 因为一定存在一只羊c ,sum = x,且c和b不能共存,既

HDU 5003 Osu! 水题 2014 ACM/ICPC Asia Regional Anshan Online

水.. #include <iostream> #include <cstdio> #include <string.h> #include <queue> #include <vector> #include <algorithm> #include <set> using namespace std; #define N 100 double a[N]; bool cmp(double x, double y){ re

HDU 5001 Walk 求从任意点出发任意走不经过某个点的概率 概率dp 2014 ACM/ICPC Asia Regional Anshan Online

题意: 给定n个点m条边的无向图 问: 从任意点出发任意走d步,从不经过某个点的概率 dp[i][j]表示从不经过i点的前提下,走了d步到达j点的概率. #include <iostream> #include <cstdio> #include <string.h> #include <queue> #include <vector> #include <algorithm> #include <set> using n

HDU 4998 Rotate 计算几何 2014 ACM/ICPC Asia Regional Anshan Online

题意: 有一个平面放在一个二维坐标轴上 给定n个操作 (x,y) p 表示把平面绕着(x,y) 逆时针转p弧度. 最后的结果相当于平面绕着(X, Y) 逆时针旋转了P弧度. 求:X,Y,P 思路: 任取一个三角形ABC,然后根据n个操作得到A'B'C', 然后求外心. 旋转的角度就是相加..==为啥我也不大清楚,不是本弱写的. #include <cstdio> #include <algorithm> #include <iostream> #include <

HDU 5000 Clone(离散数学+DP)(2014 ACM/ICPC Asia Regional Anshan Online)

Problem Description After eating food from Chernobyl, DRD got a super power: he could clone himself right now! He used this power for several times. He found out that this power was not as perfect as he wanted. For example, some of the cloned objects

HDU 5002 Tree(动态树LCT)(2014 ACM/ICPC Asia Regional Anshan Online)

Problem Description You are given a tree with N nodes which are numbered by integers 1..N. Each node is associated with an integer as the weight. Your task is to deal with M operations of 4 types: 1.Delete an edge (x, y) from the tree, and then add a

2014 ACM/ICPC Asia Regional Guangzhou Online Wang Xifeng&#39;s Little Plot HDU5024

一道好枚举+模拟题目.转换思维视角 这道题是我做的,规模不大N<=100,以为正常DFS搜索,于是傻乎乎的写了起来.各种条件限制模拟过程 但仔细一分析发现对每个点进行全部八个方向的遍历100X100X100^8 .100X100个点,每个点在走的时候8中选择,TLE 于是改为另一个角度: 以符合要求的点为拐弯点,朝两个垂直的方向走,求出最远的距离.这样只要对每个点各个方向的长度知道,组合一下对应的就OK. 避免了每个点深搜. PS:搜索的时候x,y写反了,导致构图出现问题,以后用[dy][dx]