牛客小白月赛83

A-小天的金银铜铁_牛客小白月赛83 (nowcoder.com)

AC代码:

#include<bits/stdc++.h>
#define endl '\n'
//#define int long long
using namespace std;
int a,b,c,d,e;
int A,B,C,D;
void solve() {
	cin>>a>>b>>c>>d>>e;
	cin>>A>>B>>C>>D;
	if(A*a+B*b+C*c-D*d>e) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
//    cin>>t;
	while(t--) {
		solve();
	}
	return 0;
}

B-小天的魔法_牛客小白月赛83 (nowcoder.com) 

一开始题目没看明白,题目的意思是一共n+m个魔法,每个魔法都可以用一次,那么肯定是贪心,均从大到小排序 

 AC代码:

#include<bits/stdc++.h>
#define endl '\n'
//#define int long long
using namespace std;
const int N=110;
int a[N],b[N];
int n,m,x;
void solve() {
	cin>>n>>m>>x;
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=1;i<=m;i++) cin>>b[i];
	sort(a+1,a+1+n,greater<int>());
	sort(b+1,b+1+m,greater<int>());
	int ans=0;
	for(int i=1;i<=min(n,m);i++){
		if(x-b[i]<=0){
			cout<<ans+1<<endl;
			return;
		}
		if(a[i]==1){
			x-=b[i];
			ans++;
		}
		else{
			x-=b[i]*a[i];
			ans+=2;
			if(x<=0){
				cout<<ans<<endl;
				return;
			}
		}
	}
	if(n<m){
		for(int i=m+1;i<=n;i++){
			x-=b[i];
			ans++;
			if(x<=0){
				cout<<ans<<endl;
				return;
			}
		}
	}
	cout<<-1<<endl;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
//    cin>>t;
	while(t--) {
		solve();
	}
	return 0;
}

C-小天的 Minecraft_牛客小白月赛83 (nowcoder.com) 

12铜粒合成一个铜镐
还需要一个工作台:4个铜粒或4个银粒或4个金粒

一共3种情况:
16铜粒  (a/16)^16
12铜粒+4银粒 C(16,12)*(a/16)^12*(b/16)^4
12铜粒+4金粒 C(16,12)*(a/16)^12*(c/16)^4

#include<bits/stdc++.h>
#include<cstdio>
#define endl '\n'
#define int long long
using namespace std;
double a,b,c;
int fac[25];
void solve() {
	cin>>a>>b>>c;
	fac[0]=1;
	for(int i=1;i<20;i++) fac[i]=1ll*fac[i-1]*i;//预处理阶乘
	double ans=pow(a/16,16)+(double)fac[16]/fac[4]/fac[12]*pow(a/16,12)*(pow(b/16,4)+pow(c/16,4));
	printf("%.10f\n",ans);
}
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
    cin>>t;
	while(t--) {
		solve();
	}
	return 0;
}

相关推荐

  1. 83

    2023-12-17 10:44:07       62 阅读
  2. 84

    2023-12-17 10:44:07       44 阅读
  3. 84 解题报告

    2023-12-17 10:44:07       58 阅读
  4. 86 A - F

    2023-12-17 10:44:07       46 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2023-12-17 10:44:07       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2023-12-17 10:44:07       100 阅读
  3. 在Django里面运行非项目文件

    2023-12-17 10:44:07       82 阅读
  4. Python语言-面向对象

    2023-12-17 10:44:07       91 阅读

热门阅读

  1. C语言指针3

    2023-12-17 10:44:07       56 阅读
  2. 用单片机控制步进电机的程序

    2023-12-17 10:44:07       60 阅读
  3. ssh连接试图写入的管道不存在

    2023-12-17 10:44:07       76 阅读
  4. 146. LRU 缓存

    2023-12-17 10:44:07       70 阅读
  5. 103个校招C++语法面试题

    2023-12-17 10:44:07       35 阅读
  6. 半导体:Gem/Secs基本协议库的开发(4)

    2023-12-17 10:44:07       58 阅读
  7. qt程序在Linux下打包的一般流程

    2023-12-17 10:44:07       73 阅读
  8. 基于SpringBoot的在线疫苗预防小程序

    2023-12-17 10:44:07       88 阅读
  9. 【Python】【PyPi】搭建本地PyPi镜像源

    2023-12-17 10:44:07       85 阅读