Top

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


博主链接

题目链接

题意:

给你一个x,让你求出两个整数a,b,满足他给的那些条件

题解:

数据范围很小就100,直接O(n*n)暴力枚举就可以了

代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e6+7;
const int mod=1e9+7;
int main(){
int x;
scanf("%d",&x);
for(int i=1;i<=x;i++){
for(int j=1;j<=i;j++){
if(i%j==0&&j*i>x){
printf("%d %d\n",i,j);
return 0;
}
}
}
printf("-1\n");
return 0;
}


未经允许不得转载: Anoyer's Blog » Codeforces Round #525 (Div. 2) (2)-A. Ehab and another construction problem