当前位置:网站首页>P1794 求解好多鱼问题
P1794 求解好多鱼问题
2022-04-22 18:50:00 【Recurss】
题目描述
牛牛有一个鱼缸,鱼缸里面已经有 n 条鱼,每条鱼的大小为 fishSize[i] (1<i<n, {均为正整数})fishSize[i](1<i<n,均为正整数),牛牛现在想把新捕捉的鱼放人鱼缸。鱼缸里存在着大鱼吃小鱼的 定律。经过观察,牛牛发现一条鱼 A 的大小为另外一条鱼 B 的大小的 2~10 倍(包括 22 倍大小和 10 倍大小)时鱼 A 会吃掉鱼 B。考虑到这个情况,牛牛要放入的鱼需要保证以下几点: (1)放进去的鱼是安全的,不会被其他鱼吃掉。 (2)这条鱼放进去也不能吃掉其他鱼。 (3)鱼缸里面存在的鱼已经相处了很久,不考虑它们互相捕食。 现在知道新放入鱼的大小范围 [minSize,maxSize][minSize,maxSize] (考虑鱼的大小都是用整数表示),牛牛想知道有多少种大小的鱼可以放入这个鱼缸。
输入描述
输入数据包括 3 行, 第 1 行为新放入鱼的尺寸范围 [minSize, maxSize][minSize,maxSize],以空格分隔; 第 2 行为鱼缸里面已经有鱼的数量 n(1≤n); 第 3 行为已经有的鱼的大小fishSize[i](1≤fishSize[i]),以空格分隔。
输出描述
输出有多少种大小的鱼可以放入这个鱼缸,考虑鱼的大小都是用整数表示。
样例输入
Copy to Clipboard
1 12 1 1
样例输出
Copy to Clipboard
3
/*
* @Description: To iterate is human, to recurse divine.
* @Autor: Recursion
* @Date: 2022-04-21 22:11:17
* @LastEditTime: 2022-04-21 23:27:45
*/
#include <bits/stdc++.h>
#define LL long long
using namespace std;
const int maxn = 1e6 + 10;
const int mod = 1e9 + 7;
const int INF = 1e9 + 10;
const int N = 1e6;
int n;
int fish[N+10];
int a[N];
int l,r;
int ans;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
while(cin >> l >> r >> n){
for(int i = 1;i <= n;i ++){
cin >> fish[i];
}
ans = 0;
for(int i = l;i <= r;i ++){
bool flag = true;
for(int j = 1;j <= n;j ++){
if(i / fish[j] <= 10&&i / fish[j] >= 2){
if(i/fish[j]==10&&i%fish[j]!=0){
continue;
}
flag = false;
break;
}
}
for(int j = 1;j <= n;j ++){
if(fish[j] / i >= 2&&fish[j] / i <= 10){
if(fish[j]/i==10&&fish[j]%i!=0){
continue;
}
flag = false;
break;
}
}
if(flag)
ans++;
}
cout << ans << endl;
}
return 0;
}
版权声明
本文为[Recurss]所创,转载请带上原文链接,感谢
https://blog.csdn.net/Recursions/article/details/124334685
边栏推荐
- Compare the difference between the two lists. Each element of the list is a string
- DL之YoloV3:YoloV3论文《YOLOv3: An Incremental Improvement》的翻译与解读
- Win10问题篇:一次性永久关闭win10系统自动更新
- 高并发之——深度解析ScheduledThreadPoolExecutor类的源代码
- Take you to understand the principle of highly flexible spark architecture
- mmdeploy快速上手
- nodejs如何预防xss攻击
- 【网络安全】Duomicms的变量覆盖漏洞从白盒测试到实战
- Mmdeploy quick start
- 如何做好性能压测:压测环境的设计和搭建
猜你喜欢
![[extensive reading of papers] eating embedded learning by comprehensive transcription of heterogeneous information networks](/img/d7/cb6fd42609cbf2104ef89cf8d9d5ba.png)
[extensive reading of papers] eating embedded learning by comprehensive transcription of heterogeneous information networks

我们需要什么样的数据库产品

nodejs如何预防xss攻击

【网络安全】Duomicms的变量覆盖漏洞从白盒测试到实战

STC current interrupt list of all series

What are the advantages of enterprise communication software compared with other communication software

jsp学习(九.Filter过滤器、通配符和Cookie处理)

Win10 problems: one-time permanent shutdown and automatic update of win10 system

Popular grass planting product forecast, guess the top 3 to get a red envelope!

What kind of database products do we need
随机推荐
DL之YoloV3:YoloV3论文《YOLOv3: An Incremental Improvement》的翻译与解读
What kind of database products do we need
STC目前所有系列的中断列表
带你了解极具弹性的Spark架构的原理
It's fun to learn programming. Why don't you know where to start when you do a project alone?
力扣-64.最小路径和
每日AI前沿术语:绿色AI(Green AI)
Nodejs file operation
C# 将OFD转为PDF
JSP learning (VIII. JDBC and file upload processing project)
Use bitnami PostgreSQL docker image to quickly set up stream replication clusters
【最佳实践】巡检项:内容分发网络(CDN)开启URL鉴权
Flink 最佳实践:TDSQL Connector 的使用(上)
2022年安全、下单速度快、费用低的期货公司推荐?
运维工具那么多,选择哪个好? 跟着我3秒搞定
Compare the difference between the two lists. Each element of the list is a string
Some indicators in text classification
类和对象—5
Kellerman Software .NET SFTP Library
Recommendation of safe, fast and low-cost futures companies in 2022?