qlu_新生赛_2019

两琴键间的音为多少
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*0 3, 4 6 8 9 11 13 15,16 18 20 21 23 25 27,28 
30 32 33 35 37 39,40 42 44 45 47 49 51,
52 54 56 57 59 61 63,64 66 68 69 71 73 75
,76 78 80 81 83 85 87,88*/

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<string.h>
#include<string>
#include<cmath>
#include<set>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<bits/stdc++.h>
typedef long long ll; 
using namespace std;
	
	/* 本来想着要判断各个字母的前缀,后来发现还可以
	跨组别来求相隔的半音,所以应该想到要直接用map把
	这个按键的名字当做一个下标存下来 
	
	现代音乐用七个英文字母 C D E F G A B(或其小写)来标记音名。
这七个不同高低的音,其相邻音之间的音高距离,有半音和全音之分,其中E与F 和 B与C 之间为半音关系,其余相邻音之间为全音关系。
现代钢琴键盘上的全音和半音
相邻两个琴键(包括白健和黑键)构成半音,相隔一个琴键的两键之间构成全音。
	*/
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int case1;
	map<string,int>shu;//map按key的ascii进行排序,而不是按输入顺序 
	cin>>case1;
	string name[52]={"A_2","B_2",
	"C_1","D_1","E_1","F_1","G_1","A_1","B_1","C","D"
	,"E","F","G","A","B","c","d","e","f","g","a","b","c^1","d^1"
	,"e^1","f^1","g^1","a^1","b^1","c^2","d^2","e^2","f^2","g^2","a^2","b^2","c^3","d^3"
	,"e^3","f^3","g^3","a^3","b^3","c^4","d^4","e^4","f^4","g^4","a^4","b^4","c^5"};
	
	int zhi[52]={
		0,3,4,6,8,9,11,13,15,16,
		18,20,21,23,25,27,28,30,32,33,
		35,37,39,40,42,44,45,47,49,51,
		52,54,56,57,59,61,63,64,66,68,69,71,73,75
		,76,78,80,81,83,85,87,88};
	
	for(int i=0;i<52;i++){
		shu.insert(make_pair(name[i],zhi[i]));
	}
//	for(map<string,int>::iterator it=shu.begin();it!=shu.end();it++){
//		cout<<it->first<<" "<<it->second<<endl;
//	}
	while(case1--) {
		string s1,s2;
		cin>>s1>>s2;
		cout<<abs(shu[s2]-shu[s1])<<endl;
	} 
}
讨伐青蛙

这里的青蛙比较的神奇,每个青蛙有自身的稀有值和体积。其中稀有值越高的青蛙讨伐后获得报酬能够越多,体积越小的青蛙讨伐后获得的报酬也能越多。阿库娅与和真并不想错失这一个讨伐青蛙的机会,所以他们想尽可能的使自己所能获得报酬最大。这里可以认为他们的力量无穷大,想讨伐哪只青蛙就一定能讨伐成功(虽然不大现实)。
在讨伐量固定的情况下,阿库娅与和真制定了两个讨伐计划,第一个是令稀有值之和最大,第二个是令体积之和最小,请分别计算第一种计划的最大稀有值之和,还有第二种计划的最小的体积之和。
Input输入包含多组测试数据。第一行一个T(1≤????≤5)代表测试数据组数。之后每组测试数据开头包含两个正整数n,m (1≤????≤????≤100)代表青蛙的数量n和这次需要讨伐青蛙的总数m。之后会有n行,每行包含两个个正整数a, b(1≤????,????≤1012)分别代表每只青蛙的稀有值,体积。
Output对于每组测试数据输出两个正整数分别代表所能讨伐的最大稀有值之和与最小的体积之和。

upload successful

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include<iostream>
#include<algorithm>
typedef long long ll; 
using namespace std;
const int maxn=110;
struct ani{
	ll x;
	ll y;
	
}an[maxn];


bool cmp1(ani a,ani b){
	return a.x>b.x;
}
	bool cmp2(ani a,ani b){
		return a.y<b.y;
	}
	
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	
	int T,n,m;
	cin>>T;
	while(T--){
		ll ans=0,ans1=0;
		cin>>n>>m;
		for(int i=0;i<n;i++){
			cin>>an[i].x>>an[i].y;
			
		}
		sort(an,an+n,cmp1);
		for(int j=0;j<m;j++)ans+=an[j].x;
		cout<<ans<<" ";
		sort(an,an+n,cmp2);
		for(int j=0;j<m;j++)ans1+=an[j].y;
		cout<<ans1<<endl;
		
	}

}
cet4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include<iostream>
typedef long long ll; 
using namespace std;
int main(){
	int T;
	ll a,b,c;
	ll ans;
	cin>>T;
	while(T--){
		cin>>a>>b>>c;
		if(((a-b)<1)&&c<=3500||(a-b)==0){
			cout<<"impossible"<<endl;
		}else{
			ans=3500/(a-b);
			if((3500%(a-b))>0)ans++;
			if(ans>c){
					cout<<"impossible"<<endl;
			}else{
				cout<<ans<<endl;
			}
		}
		
	} 
	
}

/*
这一题一定要预判a-b的值是否为0 
比如说:
①除以零
②数组越界:int a[3]; a[10000000]=10;
③指针越界:int * p; p=(int *)malloc(5 * sizeof(int)); *(p+1000000)=10;
④使用已经释放的空间:int * p; p=(int *)malloc(5 * sizeof(int));free(p); *p=10;
⑤数组开得太大,超出了栈的范围,造成栈溢出:int a[100000000];
*/
H. 天野阳菜的祈祷
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<set>
#include<vector>
#include<queue>
#include<stack>
#include<map>
typedef long long ll; 
using namespace std;
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int case1;
	cin>>case1;
	while(case1--){
		string s,tmp;
		cin>>s;
		if(s=="Rough")
		{
			cin>>tmp;
			cout<<"It will be a hard work!"<<endl; 
		}
		else if(s=="Sunny"){
			cout<<"Stay"<<endl;  
		}
		else{
			cout<<"Let us go!"<<endl;
		}
	}
}
I 2333
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#include<iostream>
typedef long long ll; 
using namespace std;
const int maxn=1e7+5;
int arr[maxn]={2,3,3};

//数据开到1e4以上就不能在main函数里面定义数组了,否则程序会
//直接蹦 ,这一题打表来做 
int main(){
	int T,case1;
	
	int cur=1;
	int last=2;
	int i=3; 
	while(i<maxn){
		if(arr[last]==3){
			if(arr[cur]==3){
				arr[i]=2;
				arr[i+1]=2;
				arr[i+2]=2;
				i=i+3;	
				last+=3;
			}else{
				arr[i]=2;
				arr[i+1]=2;
				i=i+2;
				last+=2;
			}
		}else{
			if(arr[cur]==3){
				arr[i]=3;
				arr[i+1]=3;
				arr[i+2]=3;
				i=i+3;	
				last+=3;
			}else{
				arr[i]=3;
				arr[i+1]=3;
				i=i+2;
				last+=2;
			}
		}
		cur++;
	}
	
//	for(int i=0;i<10000;i++)cout<<arr[i]<<" ";
	cin>>T;
	while(T--){
	cin>>case1;
	cout<<arr[case1-1]<<endl;	
	}
	
}
解法二:
#include<bits/stdc++.h>
using namespace std;
const int xa=1e7+5;
int a[xa];
int main()
{
	int p;
	cin>>p;
	a[0]=2;
	int pan=1;
	int shu=0;
	int i=0;
	while(shu<xa){
		if(a[i]==2){
			int t=2;
			while(t--){
				if(pan%2==1){
					a[++shu]=3;
				}else{
					a[++shu]=2;
				}
			}
			pan++;
		}
		if(a[i]==3){
			int t=3;
			while(t--){
				if(pan%2==1){
					a[++shu]=3;
				}else{
					a[++shu]=2;
				}
			}
			pan++;
		}
		i++;
	}
	int x;
	while(p--){
		cin>>x;
		cout<<a[x-1]<<endl;
	}
 }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
该资源内项目源码是个人的课程设、毕业设,代码都测试ok,都是运行成功后才上传资源,答辩评审平均分达到96分,放心下载使用! ## 项目备注 1、该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的,请放心下载使用! 2、本项目适合算机相关专业(如科、人工智能、通信工程、自动化、电子信息等)的在校学生、老师或者企业员工下载学习,也适合小白学习进阶,当然也可作为毕设项目、课程设、作业、项目初期立项演示等。 3、如果基础还行,也可在此代码基础上进行修改,以实现其他功能,也可用于毕设、课设、作业等。 下载后请首先打开README.md文件(如有),仅供学习参考, 切勿用于商业用途。 该资源内项目源码是个人的课程设,代码都测试ok,都是运行成功后才上传资源,答辩评审平均分达到96分,放心下载使用! ## 项目备注 1、该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的,请放心下载使用! 2、本项目适合算机相关专业(如科、人工智能、通信工程、自动化、电子信息等)的在校学生、老师或者企业员工下载学习,也适合小白学习进阶,当然也可作为毕设项目、课程设、作业、项目初期立项演示等。 3、如果基础还行,也可在此代码基础上进行修改,以实现其他功能,也可用于毕设、课设、作业等。 下载后请首先打开README.md文件(如有),仅供学习参考, 切勿用于商业用途。
该资源内项目源码是个人的课程设、毕业设,代码都测试ok,都是运行成功后才上传资源,答辩评审平均分达到96分,放心下载使用! ## 项目备注 1、该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的,请放心下载使用! 2、本项目适合算机相关专业(如科、人工智能、通信工程、自动化、电子信息等)的在校学生、老师或者企业员工下载学习,也适合小白学习进阶,当然也可作为毕设项目、课程设、作业、项目初期立项演示等。 3、如果基础还行,也可在此代码基础上进行修改,以实现其他功能,也可用于毕设、课设、作业等。 下载后请首先打开README.md文件(如有),仅供学习参考, 切勿用于商业用途。 该资源内项目源码是个人的课程设,代码都测试ok,都是运行成功后才上传资源,答辩评审平均分达到96分,放心下载使用! ## 项目备注 1、该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的,请放心下载使用! 2、本项目适合算机相关专业(如科、人工智能、通信工程、自动化、电子信息等)的在校学生、老师或者企业员工下载学习,也适合小白学习进阶,当然也可作为毕设项目、课程设、作业、项目初期立项演示等。 3、如果基础还行,也可在此代码基础上进行修改,以实现其他功能,也可用于毕设、课设、作业等。 下载后请首先打开README.md文件(如有),仅供学习参考, 切勿用于商业用途。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值