浙江工业大学第十九届“杭银理财杯”大学生程序设计竞赛暨全国邀请赛

7-1 Grammy Wants to Earn Big Money

Grammy wants to earn big money recently. She goes to hzbank every day, and deposits money on Mondays, Tuesdays, Wednesdays, Thursdays, and Fridays. In Saturdays and Sundays, she learns about wealth management in the bank. Today is Sunday. You want to know the number of days Grammy will deposit money in the next n days (including today).

Input:

Input contains a single integer n(1≤n≤30000), the total number of consecutive days Grammy will go to the bank.

Output:

Output a single integer x, indicating the total number of days Grammy will deposit money.

Sample Input:

3

Sample Output:

2
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int yu=(n-1)%7;
	if(yu!=6) yu%=6;
	else yu=5; 
	int sum=((n-1)/7)*5;
	cout<<sum+yu;
	return 0;
}

7-5 Recharge Cycle

Grammy is playing her favorite video game. There are 4 skills and 4 types of energy in the game, and the storage limit of energy type i is ci​. Skill i can only be activated if its corresponding type of energy is full. Activating skill i will use up all energy of type i and then produce aij​ energy of type j.

At the beginning, every type of energy is fully recharged to its own limit.

Grammy wants to find a strategy to activate the skills 114514 times, but she does not want to make it too complicated, so she decides to make every four consecutive skills to be pairwise distinct.

Can you tell Grammy if a valid ordering exists?

Input:

The first line contains 4 integers c1​,c2​,c3​,c4​(1≤ci​≤80), representing energy needed for each skill.

In the next 4 lines, the i-th line contains 4 integers ai1​,ai2​,ai3​,ai4​(0≤aij​≤80), representing the recharge parameter of each skill.

Output:

If a valid ordering exists, output Yes in one line, otherwise, output No in one line.

Sample Input 1:

20 20 20 20
10 10 10 10
10 10 10 10
10 10 10 10
10 10 10 10

Sample Output 1:

Yes

Sample Input 2:

80 80 80 80
10 10 10 10
10 10 10 10
10 10 10 10
10 10 10 10

Sample Output 2:

No

Sample Input 3:

40 40 40 40
10 10 10 10
10 10 10 10
10 10 10 10
10 10 10 10

Sample Output 3:

Yes

#include<bits/stdc++.h>
using namespace std;

int need[5],out[5][5];
int t[5];
int main()
{
	for(int i=1;i<=4;i++) cin>>need[i];
	for(int i=1;i<=4;i++){
		for(int j=1;j<=4;j++){
			cin>>out[i][j];
			t[j]+=out[i][j];
		}
	}
	for(int i=1;i<=4;i++) {
		if(need[i]>t[i]) {
			cout<<"No";return 0;
		}
	}
	cout<<"Yes";
	
	return 0;
}

7-10 Mountain

Grammy is climbing a mountain. She can either walk a meters by spending 1 stamina, or jump c meters by spending b stamina. If her remaining stamina is less than b, she can still jump once and use up all her stamina. She wants to know how many meters she can climb if she has S stamina at the beginning.

Input:

Each test contains multiple test cases. The first line contains a single integer T (1≤T≤30000) --- the number of test cases. Description of the test cases follows.

The only line for each testcase contains 4 integers in one line, a,b,c,S(1≤a,b,c,S≤109).

Output:

For each testcase, output a single integer, representing the maximum distance(in meters) Grammy can climb.

Sample Input:

4
1 1 4 5
1 4 1 9
1 9 8 10
114 514 1919 810

Sample Output:

20
9
17
94145
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,j,n) for(int i=j;i<n;i++)
#define pi acos(-1.0)
ll n;
int main() {
	ll t;
	cin>>t;
	while(t--) {
		ll a,b,c,s;
		cin>>a>>b>>c>>s;
		ll S=0;
		if(a*b>=c) {
			S=(s-1)*a;
			S+=max(a,c);
		} else {//花费b个耐力走c
		if(s%b!=0){
			S=s/b*c;
			
			s%=b;//剩下的小于b的耐力
			if(s==0)
			S+=0;
			
			else if(s==1)
			S+=max(a,c);
			
			else if(s>1){
			S+=(s-1)*a+max(a,c);
			}
		}
		else {
			
			S+=(s/b)*c+(b-1)*a;
		}
			
		}
		cout<<S<<endl;
	}
	return 0;
}

7-13 A Chinese Idiom

There is an ancient Chinese saying: the larger the watermelon, the larger the watermelon rind.

Grammy is a critically minded girl. She thinks this idiom is incorrect in some special situations. In order to support her, you want to find such an example.

You found two round watermelons. The smaller one has radius r1​, you cut it apart and figured out that its rind has thickness d. The larger one has radius r2​. Before cutting it open, you want to know the maximum thickness of the second rind to let the volume of the second watermelon rind to be smaller than the volume of the first watermelon rind.

Note that the watermelons are perfectly ball-shaped. A watermelon has two parts --- watermelon pulp and watermelon rind. The watermelon pulp is also ball-shaped and it is concentric with the watermelon itself.

Input:

Each test contains multiple test cases. The first line contains a single integer T (1≤T≤30000) --- the number of test cases. Description of the test cases follows.

The only line for each testcase contains three integers in one line, r1​,r2​,d(1≤d<r1​<r2​≤1000).

Output:

For each testcase, output one real number in a line, representing the maximum thickness of the second watermelon rind.

Your answer will be considered correct if its absolute or relative error does not exceed 10−4.

Sample Input:

2
2 3 1
5 7 1

Sample Output:

0.2855823834
0.4423278138
#include<bits/stdc++.h>
using namespace std;
double a,b,c,d;
double LF(double x){
	return x*x*x;
}
double f(double x){
	return a*x*x*x+b*x*x+c*x+d;
}
int main(){
	int T;
	cin>>T;
	while(T--){
		double r1,r2,dd,x,k;
	scanf("%lf%lf%lf",&r1,&r2,&dd);
	k=LF(r2)-(LF(r1)-(LF(r1-dd)));
	a=-1*1.;
	b=3.*r2;
	c=(-3)*r2*r2*1.;
	d=LF(r2)-k;
	double xl,xr,xm;
    
 
	for(int i=0;i<=1000;i++){
		xl=i,xr=i+1;
		if(f(xl)==0) printf("%.4lf\n",xl);
		else if(f(xl)*f(xr)<0){
				while(xr-xl>=0.000001){
					xm=(xl+xr)/2;
					if(f(xm)*f(xl)<=0) xr=xm;
					else xl=xm;
				}
			printf("%.10lf\n",xl);
		}
		
	}

	}
	
	
	
	return 0;
}
/*
1 -5 -4 20
2 3 1
*/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值