ICPC冬令营(1.19)

A - Maya Calendar
在这里插入图片描述在这里插入图片描述在这里插入图片描述在这里插入图片描述在这里插入图片描述代码:

#include<bits/stdc++.h>
using namespace std;
char s1[20][10]={"pop","no","zip","zotz","tzec","xul","yoxkin","mol","chen","yax","zac","ceh","mac","kankin","muan","pax","koyab","cumhu","uayet"};
char s2[20][10]={"imix","ik","akbal","kan","chicchan","cimi","manik","lamat","muluk","ok","chuen","eb","ben","ix","mem","cib","caban","eznab","canac","ahau"};
int n,cur;
struct data{
	int day;
	char month[20];
	int year;
}h,t;

int main(){
	while(scanf("%d",&n)!=EOF){
		cur = 0;
		cout << n << endl;
		while(n--){
		cin >> h.day >> h.month >> h.year;
		for(int i=0;i<19;i++){
			if(strcmp(h.month,s1[i])==0)//比较两个字符串是否相等用strcmp,返回值为0,即相等 
			{
				cur = h.year*365 + 	20*i + h.day;//不必纠结最后一月与前几个月的区别,因为都是20*对应的月份减1 
				break;
			}
		}
		if(t.year%260==0){
			cout << "13 ahau " << t.year - 1 << endl;
		}	
		else{
		t.year = cur /260;
		cur %= 260;
		cout << cur%13+1 << " " << s2[cur%20] << " " <<  t.year << endl;			
		}
		}
	}
	return 0;	
}

B - Diplomatic License

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

//求两点终点坐标 
#include<iostream>
using namespace std;
struct Point{
	long long x,y;
}first,last,now;
int  n;

int main(){
	while(scanf("%d",&n)!=EOF){
		cout << n;
		cin >> first.x >> first.y;
		last = first;
		for(int i=2;i<=n;i++){
			cin >> now.x >> now.y;
			printf(" %.6lf %.6lf",(last.x+now.x)/2.0,(last.y+now.y)/2.0);
			last = now;
		}
		printf(" %.6lf %.6lf",(last.x+first.x)/2.0,(last.y+first.y)/2.0);
		cout << endl;	
	}
}

C - “Accordian” Patience
在这里插入图片描述
在这里插入图片描述在这里插入图片描述在这里插入图片描述主要是用数组模拟线性表

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

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

//用数组模拟存储链表 or STL
#include<bits/stdc++.h>
using namespace std;
const int N = 1e6+5;
char s[N];

int main(){
	while(~scanf("%s",s+1)){
		int next[N] = {0};
		int cur = 0,last = 0;
		for(int i=1;s[i];i++){ //挨个遍历每个字符,直到s[i]不存在 
			if(s[i]=='[') cur = 0;
			if(s[i]==']')cur = last;
			else {//模拟链表的插入 
				next[i] = next[cur];
				next[cur] = i;
				if(cur == last) last = i;
				cur = i;
			} 
		}
		for(int i = next[0];i!=0;i=next[i])
			if(s[i]!='['&&s[i]!=']')	
				cout << s[i];
		cout << endl; 
	}
	return 0;
}

题目连接:https://vjudge.net/problem/UVA-11988

E - Satellites

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

//
#include<bits/stdc++.h>
#include<cmath>//sin函数 
using namespace std;
#define r 6440
double s,a,ad,cd; 
char str[10];
int main(){
	while(scanf("%d%d%s",&s,&a,str)!=EOF){
		if(str[0]=='m'){
			a = a / 60.0;  
		}
		double angle = M_PI * a /180;
		double arc = angle *(s+r);//表示圆弧距离
		double dis = 2*(s+r)*sin(angle/2);//直线距离
		if(a>180)arc = 2*M_PI*(s+r) - arc;
		printf("%.6f%.6f\n",arc,dis);
	}
}
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值