跳到正文

题解

P10781 题解

Vitamin_B约 1 分钟
原文
文章信息与版本

文章信息

发布
2024年7月14日
收录
2025年12月12日
更新
2026年11月8日
篇幅
约 1 分钟
题目
P10781

版本

  1. v1当前

思路

首先不难发现 tt 是一个单峰函数且开口向下,所以我们只要依次枚举时间,一旦发现温度有不上升的趋势就输出。

代码

C++
# include <bits/stdc++.h>
# define I return
# define AK 0
# define IOI ;
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
int t, n, k;
double now;
int main () {
	ios::sync_with_stdio (0);
	cin.tie (0);
	cout.tie (0);
	cin >> t;
	while (t --) {
		now = 0;
		cin >> n >> k;
		for (int i = 1; i <= n; ++ i)
			if (now / i + k <= now)
				goto print;
			else
				now = now / i + k;
print:
		cout << fixed << setprecision (1) << now << '\n';
	}
	I AK IOI
}
原文