题解 | 构造数对

构造数对

https://www.nowcoder.com/practice/c16b86c1149a43eaaa0fd85aaee51290

#include<bits/stdc++.h>
using namespace std;

using ll=long long;
using ull=unsigned long long;
using i128=__int128_t;
using u128=__uint128_t;
using ld=long double;

void solve()
{
	int x;//x范围很小 直接暴力枚举即可
	cin >> x;
	for(int i=1;i<=x;i++)
	{
		for(int j=i;j<=x;j+=i)
		{
			if(i*j>x&&(double)i/j<x)
			{
				cout << j << " " << i;
				return;
			}
		}
	}
	cout << -1;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int t=1;
	//cin >> t;
	
	while(t--)
	{
		solve();
	}
	return 0;
}

全部评论

相关推荐

迷茫的大四🐶:28?别太离谱,研究生出来也得25至少了
牛客吐槽大会
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务