寒假集训1.19

寒假集训1.19

A - Maya Calendar

During his last sabbatical, professor M. A. Ya made a surprising discovery about the old Maya calendar. From an old knotted message, professor discovered that the Maya civilization used a 365 day long year, called Haab, which had 19 months. Each of the first 18 months was 20 days long, and the names of the months were pop, no, zip, zotz, tzec, xul, yoxkin, mol, chen, yax, zac, ceh, mac, kankin, muan, pax, koyab, cumhu. Instead of having names, the days of the months were denoted by numbers starting from 0 to 19. The last month of Haab was called uayet and had 5 days denoted by numbers 0, 1, 2, 3, 4. The Maya believed that this month was unlucky, the court of justice was not in session, the trade stopped, people did not even sweep the floor.

For religious purposes, the Maya used another calendar in which the year was called Tzolkin (holly year). The year was divided into thirteen periods, each 20 days long. Each day was denoted by a pair consisting of a number and the name of the day. They used 20 names: imix, ik, akbal, kan, chicchan, cimi, manik, lamat, muluk, ok, chuen, eb, ben, ix, mem, cib, caban, eznab, canac, ahau and 13 numbers; both in cycles.

Notice that each day has an unambiguous description. For example, at the beginning of the year the days were described as follows:

1 imix, 2 ik, 3 akbal, 4 kan, 5 chicchan, 6 cimi, 7 manik, 8 lamat, 9 muluk, 10 ok, 11 chuen, 12 eb, 13 ben, 1 ix, 2 mem, 3 cib, 4 caban, 5 eznab, 6 canac, 7 ahau, and again in the next period 8 imix, 9 ik, 10 akbal . . .

Years (both Haab and Tzolkin) were denoted by numbers 0, 1, : : : , where the number 0 was the beginning of the world. Thus, the first day was:

Haab: 0. pop 0

Tzolkin: 1 imix 0
Help professor M. A. Ya and write a program for him to convert the dates from the Haab calendar to the Tzolkin calendar.

Input

The date in Haab is given in the following format:
NumberOfTheDay. Month Year

The first line of the input file contains the number of the input dates in the file. The next n lines contain n dates in the Haab calendar format, each in separate line. The year is smaller then 5000.

Output

The date in Tzolkin should be in the following format:
Number NameOfTheDay Year

The first line of the output file contains the number of the output dates. In the next n lines, there are dates in the Tzolkin calendar format, in the order corresponding to the input dates.

Sample Input

3
10. zac 0
0. pop 0
10. zac 1995

Sample Output

3
3 chuen 0
1 imix 0
9 cimi 2801

$\mathbf{题目大意} $

玛雅人用Haab历法,一年有365天,每年19个月,前十八个月每月有20天,Haab历的最后一个月叫uayet,这月只有5天,因宗教原因,玛雅人还是用了Tzolkin历法,一年被分为13个不同的时期,每个时期20天。0表示世界的开始,所以第一天被表示成 Haab: 0. pop 0 ;Tzolkin: 1 imix 0,编写程序,把Haab历转化成Tzolkin历。

思路 :因为要转换历年,所以要计算haab历从世界开始到所给的日期,共经历了多少天,存储月份用string字符串数组存储

主要代码

		for(int j = 0; j<19;++j){
			if(p[i].month==haab[j]){
				t = j;
				break;
			}
		}
			cnt = p[i].year*365+t*20+p[i].day;//计数共过了多少天 
 year = cnt/260;// 按tzolki算经历了多少年 
		    cnt = cnt%260;//算出剩余总天数 
		    day =cnt%13+1;
		    month = cnt%20;//月份的小标(在字符串的位置)

完整代码

#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
const int N = 5000;
struct data{
	int year,day;
	string month;
}p[N];
int n;
int main(){
	string haab[] = {"pop","no","zip","zotz","tzec",
	      "xul","yoxkin","mol","chen","yax","zac","ceh",
		  "mac","kankin","muan","pax","koyab","cumhu","uayet"};
	string tzo[] = {"imix","ik","akbal","kan","chicchan","cimi",
	"manik","lamat","muluk","ok","chuen","eb","ben","ix",
	"mem","cib","caban","eznab","canac","ahau"};
	cin>>n;
	cout<<n<<endl;
	for(int i = 1; i <= n;++i){
		scanf("%d. ",&p[i].day);
		cin>>p[i].month;
		cin>>p[i].year;
		int year,month,day,t,cnt;
		for(int j = 0; j<19;++j){
			if(p[i].month==haab[j]){
				t = j;
				break;
			}
		}
			cnt = p[i].year*365+t*20+p[i].day;//计数共过了多少天 
		    year = cnt/260;// 按tzolki算经历了多少年 
		    cnt = cnt%260;//算出剩余总天数 
		    day =cnt%13+1;
		    month = cnt%20;
			cout<<day<<" "<<tzo[month]<<" "<<year<<endl;		 
	}
	return 0;
}

B - Diplomatic License

In an effort to minimize the expenses for foreign affairs the countries of the world have argued as follows. It is not enough that each country maintains diplomatic relations with at most one other country, for then, since there are more than two countries in the world, some countries cannot communicate with each other through (a chain of) diplomats.

Now, let us assume that each country maintains diplomatic relations with at most two other countries. It is an unwritten diplomatic “must be” issue that every country is treated in an equal fashion. It follows that each country maintains diplomatic relations with exactly two other countries.

International topologists have proposed a structure that fits these needs. They will arrange the countries to form a circle and let each country have diplomatic relations with its left and right neighbours. In the real world, the Foreign Office is located in every country’s capital. For simplicity, let us assume that its location is given as a point in a two-dimensional plane. If you connect the Foreign Offices of the diplomatically related countries by a straight line, the result is a polygon.

It is now necessary to establish locations for bilateral diplomatic meetings. Again, for diplomatic reasons, it is necessary that both diplomats will have to travel equal distances to the location. For efficiency reasons, the travel distance should be minimized. Get ready for your task!

Input

The input contains several testcases. Each starts with the number n of countries involved. You may assume that n>=3 is an odd number. Then follow n pairs of x- and y-coordinates denoting the locations of the Foreign Offices. The coordinates of the Foreign Offices are integer numbers whose absolute value is less than 1012. The countries are arranged in the same order as they appear in the input. Additionally, the first country is a neighbour of the last country in the list.

Output

For each test case output the number of meeting locations (=n) followed by the x- and y-coordinates of the locations. The order of the meeting locations should be the same as specified by the input order. Start with the meeting locations for the first two countries up to the last two countries. Finally output the meeting location for the n-th and the first country.

Sample Input

5 10 2 18 2 22 6 14 18 10 18
3 -4 6 -2 4 -2 6
3 -8 12 4 8 6 12

Sample Output

5 14.000000 2.000000 20.000000 4.000000 18.000000 12.000000 12.000000 18.000000 10.000000 10.000000
3 -3.000000 5.000000 -2.000000 5.000000 -3.000000 6.000000
3 -2.000000 10.000000 5.000000 10.000000 -1.000000 12.000000

Hint

Note that the output can be interpreted as a polygon as well. The relationship between the sample input and output polygons is illustrated in the figure on the page of Problem 1940. To generate further sample input you may use your solution to that problem.

题目大意:给出n(奇数)个国家,n对坐标表示外交部的位置,给出国家之间的双边外交会议地点位置的x和y坐标输出的会议地点的顺序应与输入给出的顺序相同。从排在最前的两个国家的会议地点开始,一直到排在最后面的两个国家的会议地点,最后输出第n个国家和第一个国家的会议地点

思路:题目提示国家质检组成一个圈可以被看成一个多边形,而外交部要使两个相邻国家到外交部的距离相等,所以我们只需要求出每对相邻国家的中点坐标即可

完整代码:

#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int n;
const int N = 1e4+6;
std::pair<double,double>loc[N];
int main(){
	while(cin>>n){
		cout<<n;
		for(int i = 1;i<=n;++i){
	    	cin>>loc[i].first>>loc[i].second;
		}
		for(int i = 1;i<=n-1;++i){
			printf(" %.6f %.6f",(loc[i].first+loc[i+1].first)/2,(loc[i].second+loc[i+1].second)/2);
		}	
		printf(" %.6f %.6f",(loc[1].first+loc[n].first)/2,(loc[1].second+loc[n].second)/2);
		cout<<endl;
	}

	
	return 0;
}

C - “Accordian” Patience

You are to simulate the playing of games of ``Accordian’’ patience, the rules for which are as follows:

Deal cards one by one in a row from left to right, not overlapping. Whenever the card matches its immediate neighbour on the left, or matches the third card to the left, it may be moved onto that card. Cards match if they are of the same suit or same rank. After making a move, look to see if it has made additional moves possible. Only the top card of each pile may be moved at any given time. Gaps between piles should be closed up as soon as they appear by moving all piles on the right of the gap one position to the left. Deal out the whole pack, combining cards towards the left whenever possible. The game is won if the pack is reduced to a single pile.
Situations can arise where more than one play is possible. Where two cards may be moved, you should adopt the strategy of always moving the leftmost card possible. Where a card may be moved either one position to the left or three positions to the left, move it three positions.

Input

Input data to the program specifies the order in which cards are dealt from the pack. The input contains pairs of lines, each line containing 26 cards separated by single space characters. The final line of the input file contains a # as its first character. Cards are represented as a two character code. The first character is the face-value (A=Ace, 2-9, T=10, J=Jack, Q=Queen, K=King) and the second character is the suit (C=Clubs, D=Diamonds, H=Hearts, S=Spades).

Output

One line of output must be produced for each pair of lines (that between them describe a pack of 52 cards) in the input. Each line of output shows the number of cards in each of the piles remaining after playing ``Accordian patience’’ with the pack of cards as described by the corresponding pairs of input lines.

Sample Input

QD AD 8H 5S 3H 5H TC 4D JH KS 6H 8S JS AC AS 8D 2H QS TS 3S AH 4H TH TD 3C 6S
8C 7D 4C 4S 7S 9H 7C 5D 2S KD 2D QH JD 6D 9D JC 2C KH 3D QC 6C 9S KC 7H 9C 5C
AC 2C 3C 4C 5C 6C 7C 8C 9C TC JC QC KC AD 2D 3D 4D 5D 6D 7D 8D TD 9D JD QD KD
AH 2H 3H 4H 5H 6H 7H 8H 9H KH 6S QH TH AS 2S 3S 4S 5S JH 7S 8S 9S TS JS QS KS
#

Sample Output

6 piles remaining: 40 8 1 1 1 1
1 piles remaining: 52

题目大意:模拟一个纸牌游戏,规则如下

请您模拟"Accordian" Patience游戏,规则如下:

• 玩家将一副扑克牌一张一张地发牌,从左到右排成一排,不能重叠。只要一张扑克牌和左边的第一张牌或左边的第三张牌相匹配,就将这张扑克牌移被匹配的牌的上面。所谓两张牌匹配是这两张牌的数值(数字或字母)相同或花色相同。每当移了一张牌之后,就再检查看这张牌能否继续往左移,每次只能移在牌堆顶部的牌。本游戏可以将两个牌堆变成一个牌堆,如果根据规则,可以将右侧牌堆的牌一张一张地移到左侧牌堆,就可以变成一个牌堆。游戏尽可能地把牌往左边移动。如果最后只有一个牌堆,玩家就赢了。

• 在游戏过程中,玩家可能会遇上一次可以有多种选择的情况。当两张牌都可以被移动时,就移动最左边的牌。如果一张牌可以向左移动一个位置或向左移动三个位置,则将其移动三个位置。

思路:链表问题,用pre[]指向前一张牌,last[]指向后一张牌,s [ ] [ ] []第三维存储纸牌的面值和花色,模拟游戏过程,自己做没做出来,自己对链表部分代码实现掌握的有所欠缺,看了乐哥的代码,太强了。。

#include<iostream>
#include<cstdio>
using namespace std;
const int N = 60;
char s[N][N][N];
int pre[N],last[N],mp[N],sum[N],ans[N];
int getp3(int x){
	int p1 = pre[x],p2 = pre[p1],p3 = pre[p2];
	return p3;
}
int getp1(int x){
	int p1 = pre[x];
	return p1;
}
int main(){
	while(1){
		scanf("%s",s[1][1]);
			if(s[1][1][0]=='#') break;
			last[1] = 2,sum[1]=1,last[0]=1;
			for(int i = 2;i<=52;++i){
				scanf("%s",s[i][1]);
				pre[i] = i-1;
				last[i] = i+1;
				sum[i] = 1;
			}
			for(int i = 2;i<=52;i = last[i]){
				int p = getp3(i);
				if(p>0&&(s[p][sum[p]][0]==s[i][sum[i]][0]||
				s[p][sum[p]][1]==s[i][sum[i]][1])){
					sum[p]++;
					s[p][sum[p]][0]=s[i][sum[i]][0];
					s[p][sum[p]][1]=s[i][sum[i]][1];
					sum[i]--;
					if(sum[i]==0){
						last[pre[i]] = last[i];
						pre[last[i]] = pre[i];
					}
					i = p-1;
					continue;
				}
				p = getp1(i);
				if(p>0&&(s[p][sum[p]][0]==s[i][sum[i]][0]||
				s[p][sum[p]][1]==s[i][sum[i]][1])){
					sum[p]++;
					s[p][sum[p]][0]=s[i][sum[i]][0];
					s[p][sum[p]][1]=s[i][sum[i]][1];
					sum[i]--;
					if(sum[i]==0){
						last[pre[i]] = last[i];
						pre[last[i]] = pre[i];
					}
					i = p-1;
					continue;
				}
			}
			int cnt = 0;
			for(int i = 1;i<=52;++i){
				if(sum[i]) ans[cnt++] = sum[i];
			}
			printf("%d piles remaining: %d",cnt,ans[0]);
			for(int i = 1;i<cnt;++i){
				printf(" %d",ans[i]);
			}
			printf("\n");
		}
	return 0;
} 

D - Broken Keyboard (a.k.a. Beiju Text)

在这里插入图片描述

题目大意:某人正在用一个坏键盘键入一个长文本。这个键盘的问题是时不时“Home”键或“End”键会在您输入

文本时自动按下。您并没有意识到这个问题,因为你只关注文本,甚至没有打开显示器。完成键入后,您打开显示器,在屏幕上看到文本。在中文里,我们称之为悲剧。请您找到悲剧的文本

思路:用数组模拟链表,next数组代替链表中的next指针,next[i]存储第i个字符的下一个字符下标

next[i] = i+1,设置变量cur表示光标,cur不是当前遍历到的位置i,是表示位置i的字符应该插入在cur的右侧。如果当前字符为’ [ ‘,光标cur就跳到字符串的最前面,即cur=0;如果’ ] ',光标就跳到字符串的最后面,即cur=last,其中变量last保存当前字符串最右端的下标。

主要代码:

str="*"+str;
		for(int i =1;str[i];++i){
			if(str[i]=='[') cur = 0;//光标跳到字符串前 
			else if(str[i]==']') cur = last;//跳到字符串后 
			else{
				Next[i] = Next[cur];//插入链表 
				Next[cur] = i;
				if(cur==last) last = i;
				cur = i;
			}
		}

完整代码:

#include<iostream>
#include<cstdio>
using namespace std;
const int N = 1e5+6;
int Next[N];
int main(){
	string str;
	while(getline(cin,str)){
		int cur = 0,last = 0;
		Next[0]=0;
		str="*"+str;
		for(int i =1;str[i];++i){
			if(str[i]=='[') cur = 0;//光标跳到字符串前 
			else if(str[i]==']') cur = last;//跳到字符串后 
			else{
				Next[i] = Next[cur];//插入链表 
				Next[cur] = i;
				if(cur==last) last = i;
				cur = i;
			}
		}
		for(int i = Next[0];i;i = Next[i]){
			cout<<str[i];
		}
		cout<<endl;
	}
	return 0;
} 

E - Satellites

在这里插入图片描述
在这里插入图片描述

题目大意:给出人造卫星与地球的表面距离,和 两颗人造卫星与地球中心的夹角,min字符串代表夹角以分为单位,deg以度为单位

思路:利用公式求解[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-OeYW0deH-1611305756156)(C:\Users\29252\Pictures\题目\E2.png)]

要注意角度大于180度的情况

完整代码:

#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
#define PI acos(-1.0)
double s,a;
string str;
double r = 6440;
int main(){
	while(cin>>s>>a>>str){
		if(str[0]=='m') a/=60;
		double arc_dist = 2*PI*(r+s)*(a/360);
		double chord_dist = (r+s)*sin(a*PI/360)*2;
		if(a>180) arc_dist = 2*PI*(r+s)-arc_dist;
		printf("%.6f %.6f\n",arc_dist,chord_dist);
	}
	return 0;
} 

F - Fourth Point !!

在这里插入图片描述

题目大意:给出平行四边形中两条相邻边的端点的(x, y)坐标,请找到第四个点的(x, y)坐标。

思路:给出平行四边形中两条相邻边的端点坐标,求第4个点的坐标。要注意的是,两条相邻边的端点坐标,会有两个点的坐标是重复的;因此,要判定哪两个点的坐标是重复的。

设给出的平行四边形中两条相邻边的端点坐标为(x0 , y0),(x1 , y1), (x2 , y2)和(x3 , y3),(x0 , y0 )= (x3 , y3),求第4个点的坐标(x**a , y**b),则有x**a-x2= x1-x0,y**a-y2= y1-y0 ;得x**a=x2+x1-x0,y**a= y2+y1-y0。

完整代码:

#include<iostream>
#include<algorithm>
using namespace std;
struct node{
	double x,y;
};
int main(){
	struct node a,b,c,d;
	int x,y;
	while(~scanf("%lf%lf%lf%lf%",&a.x,&a.y,&b.x,&b.y)){
		scanf("%lf%lf%lf%lf",&c.x,&c.y,&d.x,&d.y);
	   if(a.x==c.x&&a.y==c.y)
	   	swap(a,b);
	   	if(a.x==d.x&&a.y==d.y)
		   swap(a,b),swap(c,d);
		 if(b.x==d.x&&b.y==d.y)
		   swap(c,d); 
		 printf("%.3f %.3f\n",a.x+d.x-c.x,a.y+d.y-c.y);
	}
	
	return 0;
}
 

G - The Circumference of the Circle

To calculate the circumference of a circle seems to be an easy task - provided you know its diameter. But what if you don’t?

You are given the cartesian coordinates of three non-collinear points in the plane.
Your job is to calculate the circumference of the unique circle that intersects all three points.

Input

The input will contain one or more test cases. Each test case consists of one line containing six real numbers x1,y1, x2,y2,x3,y3, representing the coordinates of the three points. The diameter of the circle determined by the three points will never exceed a million. Input is terminated by end of file.

Output

For each test case, print one line containing one real number telling the circumference of the circle determined by the three points. The circumference is to be printed accurately rounded to two decimals. The value of pi is approximately 3.141592653589793.

Sample Input

0.0 -0.5 0.5 0.0 0.0 0.5
0.0 0.0 0.0 1.0 1.0 1.0
5.0 5.0 5.0 7.0 4.0 6.0
0.0 0.0 -1.0 7.0 7.0 7.0
50.0 50.0 50.0 70.0 40.0 60.0
0.0 0.0 10.0 0.0 20.0 1.0
0.0 -500000.0 500000.0 0.0 0.0 500000.0

Sample Output

3.14
4.44
6.28
31.42
62.83
632.24
3141592.65

题目大意:给出平面上三个非共线点的笛卡尔坐标,计算这三个点相交的唯一的圆的周长

思路:设3个点分别为(x0, y0),(x1 , y1) 和(x2 , y2),圆心为 (x**m, y**m)。

公式推导:在这里插入图片描述

完整代码:

#include<iostream>
#include<cmath>
using namespace std;
double ax,ay,bx,by,cx,cy,p;
double getdis(double x,double y,double xx,double yy){
	return sqrt(pow(x-xx,2)+pow(y-yy,2));
}
int main(){
	while(cin>>ax>>ay>>bx>>by>>cx>>cy){
		double a = getdis(ax,ay,bx,by);
		double b = getdis(bx,by,cx,cy);
		double c = getdis(ax,ay,cx,cy);
		p = (a+b+c)/2;
		double s = sqrt(p*(p-a)*(p-b)*(p-c));
		double d = a*b*c/2.0/s;
		printf("%.2f\n",d*acos(-1.0));
	}
}

H - Titanic

It is a historical fact that during the legendary voyage of “Titanic” the wireless telegraph machine had delivered 6 warnings about the danger of icebergs. Each of the telegraph messages described the point where an iceberg had been noticed. The first five warnings were transferred to the captain of the ship. The sixth one came late at night and a telegraph operator did not notice that the coordinates mentioned were very close to the current ship’s position.

Write a program that will warn the operator about the danger of icebergs!

Input

The input messages are of the following format:

Message #<n>.
Received at <HH>:<MM>:<SS>. 
Current ship's coordinates are 
<X1>^<X2>'<X3>" <NL/SL> 
and <Y1>^<Y2>'<Y3>" <EL/WL>.
An iceberg was noticed at 
<A1>^<A2>'<A3>" <NL/SL> 
and <B1>^<B2>'<B3>" <EL/WL>.
===

Here is a positive integer, :: is the time of the message reception, ^’" <NL/SL> and ^’" <EL/WL> means “X1 degrees X2 minutes X3 seconds of North (South) latitude and Y1 degrees Y2 minutes Y3 seconds of East (West) longitude.”

Output

Your program should print to the output file message in the following format:

The distance to the iceberg: <s> miles.

Where should be the distance between the ship and the iceberg, (that is the length of the shortest path on the sphere between the ship and the iceberg). This distance should be printed up to (and correct to) two decimal digits. If this distance is less than (but not equal to!) 100 miles the program should print one more line with the text:

DANGER!

Sample Input

Message #513.
Received at 22:30:11. 
Current ship's coordinates are 
41^46'00" NL 
and 50^14'00" WL.
An iceberg was noticed at
41^14'11" NL 
and 51^09'00" WL.
===

Sample Output

The distance to the iceberg: 52.04 miles.
DANGER!

Hint

For simplicity of calculations assume that the Earth is an ideal sphere with the diameter of 6875 miles completely covered with water. Also you can be sure that lines in the input file break exactly as it is shown in the input samples. The ranges of the ship and the iceberg coordinates are the same as the usual range for geographical coordinates, i.e. from 0 to 90 degrees inclusively for NL/SL and from 0 to 180 degrees inclusively for EL/WL.

题目大意:本题要求您计算一个球体上两点之间的距离。直接采用计算球体上距离的公式。如果距离小于100英里,则输出:“DANGER!”

思路:已知球体上两点AB的纬度和经度,分别为(wA, jA)和(wB, jB),计算AB之间的距离公式:dist(A, B) =

*R**arccos(cos(wA)*cos(wB)cos(jA-jB)+sin(wA)sin(wB));其中R是球体的半径,默认’N’和’E’为正方向,'S’和’W’为负方向。

输入的处理相对麻烦,先把经纬度的度、分、秒转换成度,再根据东西经,南北纬取正负号。在计算距离时,度转换为弧度;然后根据球上两点距离公式求船和冰山的距离。

主要代码:

double solve(double a,double b,double c,char s[])
{
	a=a+c/3600+b/60;
	if(s[2]=='S' || s[2]=='W')
		a=-a;
	a=a*pi/180;
	return a;
}

完整代码:

#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
using namespace std;
char s[1000],s1[1000];
const double pi=acos(-1.0);
double solve(double a,double b,double c,char s[])
{
	a=a+c/3600+b/60;
	if(s[2]=='S' || s[2]=='W')
		a=-a;
	a=a*pi/180;
	return a;
}
int dblcmp(double k)
{
	if(fabs(k)<eps)
		return 0;
	return k>0?1:-1;
}
int main()
{
	double a,b,c;
	double a1,b1,a2,b2;
	while(gets(s))
	{
		gets(s);
		gets(s);
		scanf("%lf^%lf'%lf",&a,&b,&c);
		gets(s);
		a1=solve(a,b,c,s);
		scanf("and %lf^%lf'%lf",&a,&b,&c);
		gets(s);
		b1=solve(a,b,c,s);
 
		gets(s);
		scanf("%lf^%lf'%lf",&a,&b,&c);
		gets(s);
		a2=solve(a,b,c,s);
		scanf("and %lf^%lf'%lf",&a,&b,&c);
		gets(s);
		b2=solve(a,b,c,s);
		gets(s);
		double xx=6875.0/2;
		xx=xx*acos(sin(a1)*sin(a2)+cos(a1)*cos(a2)*cos(b1-b2));
		printf("The distance to the iceberg: %.2lf miles.\n",xx);
		if(dblcmp(xx-100+0.005)<0)
			printf("DANGER!\n");
	}
	return 0;
}
	return 0;
return k>0?1:-1;

}
int main()
{
double a,b,c;
double a1,b1,a2,b2;
while(gets(s))
{
gets(s);
gets(s);
scanf("%lf^%lf’%lf",&a,&b,&c);
gets(s);
a1=solve(a,b,c,s);
scanf(“and %lf^%lf’%lf”,&a,&b,&c);
gets(s);
b1=solve(a,b,c,s);

	gets(s);
	scanf("%lf^%lf'%lf",&a,&b,&c);
	gets(s);
	a2=solve(a,b,c,s);
	scanf("and %lf^%lf'%lf",&a,&b,&c);
	gets(s);
	b2=solve(a,b,c,s);
	gets(s);
	double xx=6875.0/2;
	xx=xx*acos(sin(a1)*sin(a2)+cos(a1)*cos(a2)*cos(b1-b2));
	printf("The distance to the iceberg: %.2lf miles.\n",xx);
	if(dblcmp(xx-100+0.005)<0)
		printf("DANGER!\n");
}
return 0;

}


猜你喜欢

转载自blog.csdn.net/qq_45719435/article/details/112990349