我都认识

编程入门 行业动态 更新时间:2024-10-24 22:21:23

<a href=https://www.elefans.com/category/jswz/34/1741616.html style=我都认识"/>

我都认识

链接:
来源:牛客网

题目描述
小明有个想法,假如世界上所有人都恰好认识K个人,并且每个人认识的人之间没有重复的,那么小明就间接认识了世界上所有的人!
小明又有一个想法,假如这个世界里某个人知道一条信息,他/她会传给所有他/她认识的人。
小明还有一个想法,每次信息传递都会有偏差,偏差的严重程度随信息传递的次数递增而递增。
假设小明传给他的朋友们一条信息,则偏差严重程度为1,小明的朋友们传给他们的朋友时,则偏差严重程度为2(因为传递了两次),以此类推。
小明最后想知道在这种条件下,他如果传递一条信息给N个人,偏差严重程度最大为多少?
输入描述:
输入只有一行,两个整数N,K,代表传递的人数和每个人认识的人的个数。

数据保证:0<N≤106,0<K≤10

输出描述:
输出一行,一个整数,表示最大偏差严重程度。
示例1
输入
复制
8 2
输出
复制
3
说明
小明传给他的朋友(2<8),他的朋友传给他们的朋友(2+4=6<8),他们的朋友再传给他们的朋友(6+8=14>8),因此最大严重偏差程度为3。
示例2
输入
复制
8 3
输出
复制
2
说明
小明传给他的朋友(3<8),他的朋友传给他们的朋友(3+9=12>8),因此最大严重偏差程度为2。

错了很有可能是公式推理错了,应该根据实际含义推理,不能单纯的根据样例推理

**#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <stack>
#include <map>
#include <unordered_map>
#include <vector>
#include <cmath>
#include <ext/rope>
#include <bits/stdc++.h> using namespace std;#define gt(x) x = read()
#define int long long
#define ios ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
//#define x first
//#define y secondint dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0}; //typedef __int128 INT;
typedef pair<double, int> PDI;
typedef pair<int, int> PII;
typedef unsigned long long ULL;inline int read(int out = 0)
{char c;while((c=getchar()) < 48 || c > 57);while(c >= 48 && c <= 57) out=out*10+c-48,c=getchar();return out; 
}const int N = 2e5 + 10;
const int M = 2e5 + 10;
const int mod = 1000000007;
const int PP = 13331;
const int inf = 0x3f3f3f3f;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-10;
const double PI = acos(-1);signed main(){int n, k;scanf("%lld%lld", &n, &k);int cnt = 0;
//	int ans = 0;
//	n --;int base = k;while(n > 0){//	cout << "---" << endl;n -= k;cnt ++;k = k * base;} cout << cnt << endl;return 0;
}**

长跑
链接:
来源:牛客网

题目描述
巴是一名出色的短跑运动员,但是他现在要进行长跑运动。由于他对自己的体力不自信,所以列出了这样的体力计算公式。

巴的长跑是匀速的,速度为v。他的初始体力值为C,疲劳系数为p,他在第t时刻的体力值W为:W=-pt+C。

如果巴在第t时刻的体力值<0,那么他就会身体不适呕吐晕倒。

现在给出总路径H,和C,p。

巴希望选择找出一个最小整数速度v,使他以这个速度跑步,不会出现身体不适。(整个比赛过程,包括终点)
(注1:巴所在的宇宙的时间计算皆为整型数据。如果巴在(t-1,t]的时间内体力值<0,但仍在第t时刻才会产生身体不适,同理如果在(t-1,t]时间内跑过终点,仍视为在第t时刻到达终点。)
(注2:巴是人类,所以他可以达到的最大速度<=10)
输入描述:
第1行输入三个整数H,C,p,分别代表总路程,初始体力值和疲劳系数。
数据保证:0<H≤1000,0<C≤100,0<p≤3。
输出描述:
输出一行,一个整数,代表巴可以选择的最小整数速度。如果巴不能到达终点,则输出-1。
示例1
输入
复制
10 5 1
输出
复制
2
示例2
输入
复制
13 8 4
输出
复制
7

在推公式的过程中,因为会出现很多边界问题,所以·在求解答案的过程中一定要分步求解,会减少很多错误,在有除号的时候,要分清楚是向上取整,还是向下取整,一定要分步求解,在关注数据范围的时候,题目会暗示枚举的方向,哪个数据范围比较小,答案一定是枚举哪个东西

#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <stack>
#include <map>
#include <unordered_map>
#include <vector>
#include <cmath>
#include <ext/rope>
#include <bits/stdc++.h> using namespace std;#define gt(x) x = read()
#define int long long
#define ios ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
//#define x first
//#define y secondint dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0}; //typedef __int128 INT;
typedef pair<double, int> PDI;
typedef pair<int, int> PII;
typedef unsigned long long ULL;inline int read(int out = 0)
{char c;while((c=getchar()) < 48 || c > 57);while(c >= 48 && c <= 57) out=out*10+c-48,c=getchar();return out; 
}const int N = 2e5 + 10;
const int M = 2e5 + 10;
const int mod = 1000000007;
const int PP = 13331;
const int inf = 0x3f3f3f3f;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-10;
const double PI = acos(-1);signed main(){int h, c, p;cin >> h >> c >> p;int t = c / p;int v = (h + t - 1) / t;if (v <= 10){cout << v << endl;}else  cout << "-1" << endl;return 0;
}

更多推荐

我都认识

本文发布于:2023-06-25 17:23:57,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/881935.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:我都

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!