Codeforces Round #525 (Div. 2) Ehab and another construction problem CodeForces - 1088A

本文分享了一道C++编程题的解题思路,通过双重循环遍历寻找符合条件的整数对,展示了如何利用基本的数学条件进行筛选,实现简单有效的算法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

按照题意来说,答案应该不唯一,所以直接暴力写就行了,不用想太多

#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string.h>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<set>
#include<vector>
using namespace std;
typedef long long int ll;
const int maxn =1e6+5;
const int maxm=10000;
const int mod =1e9+7;
const int INF=0x3f3f3f3f;
const double eps=1e-8;
int flag;
int main()
{
	int x;scanf("%d",&x);

	for(int a=1;a<=x;a++)
		for(int b=1;b<=x;b++)
			if(a%b==0&&a*b>x&&a/b<x)
			{
				flag=1;
				printf("%d %d\n",a,b);
				return 0;
			}
	if(!flag)printf("-1\n");
    return 0;
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值