跳到正文

题解

T714703 哈吉米 Happy Birthday!(改编自atcoder))题解

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

文章信息

发布
2025年12月25日
收录
2025年12月29日
更新
2026年11月18日
篇幅
约 1 分钟

版本

  1. v2当前
  2. v1

已经知道 x,y,z,不妨令年数为k(k大于等于0) 即要说明(x+k)=z(y+k) 显然(x-yz)是k的倍数,即(x-yz)%k==0这题就做完了,当然由于数据范围,本题需要高精度乘法,作者做了一下弊,用__int128_t类型 官方答案如下:

C++
#include <iostream>
#define int long long
using namespace std;

signed main()
{
	int x, y, z;
	cin >> x >> y >> z;
	if(x%y==0&&x/y==z)
	{
		cout << "Yes"<< endl;
		return 0;
	}
	__int128_t t = x-y*z;
	__int128_t q = z-1;
	if(t%q==0&&t>=0)
	{
		cout << "Yes"<< endl;
	}
	else
	{
		cout << "No"<< endl;
	}
	return 0;
}
原文