ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

P8344 「Wdoi-6」走在夜晚的莲台野 题解

2022-05-20 20:01:07  阅读:139  来源: 互联网

标签:ch return 木板 int 题解 P8344 Wdoi readchar include


简单结论题。

题意:

有一个能装 \(z\) 个木板的桶,你有 \(x\) 个金色木板, \(y\) 个银色木板,每放进一个金色木板,下面的银色木板都会拿出来了,问是否存在方案使所有的木板都被放进去过

思路:

最后的情况肯定是把所有的金色木板放到桶里,如果 \(z<x\),肯定无解。

然后我们贪心的考虑最多能放进去过几个银色木板,想让更多的银色木板被放进去过,那就是最后留下一个空位来放金色木板将下面的不断拿出来,容易发现这是一个等差数列,用求和公式求出最多的能放的银色木板数,与 \(y\) 做对比即可。

AC code:

/*
	Work by: TLE_Automation
*/
#include<cmath>
#include<queue>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define LL long long
#define int long long
using namespace std;

const int N = 1e6 + 10;
const int MAXN = 2e5 + 10;

inline char readchar() {
	static char buf[100000], *p1 = buf, *p2 = buf;
	return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2) ? EOF : *p1++;
}

inline int read() {
#define readchar getchar
	int res = 0, f = 0;char ch = readchar();
	for(; !isdigit(ch); ch = readchar()) if(ch == '-') f = 1;
	for(; isdigit(ch); ch = readchar()) res = (res << 1) + (res << 3) + (ch ^ '0');
	return f ? -res : res;
}

inline void print(int x) {
	if (x < 0 ) putchar('-'), x = -x;
	if (x > 9 ) print(x / 10);
	putchar(x % 10 + '0');
}

void Main() {          
	int x = read(), y = read(), z = read();
//	printf("%lld\n", ((z - 1 + z - x - 1) * ( x + 1) / 2));
	if(x > z) return puts("Merry"), void();
	if((z - 1 + z - x - 1) * ( x + 1) / 2 + 1 < y) return puts("Merry"), void();
	else return puts("Renko"), void();
}

signed main() {
	int T = read(); while(T--) Main();
	return 0; 
}

标签:ch,return,木板,int,题解,P8344,Wdoi,readchar,include
来源: https://www.cnblogs.com/tttttttle/p/16293580.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有