1. 程式人生 > >Codeforces Round #525 (Div. 2)A. Ehab and another construction problem

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

滿足 hab i++ col std other ext pro con

A. Ehab and another construction problem

題目鏈接:https://codeforc.es/contest/1088/problem/A

題意:

給出一個x,找出這樣的a,b滿足:1<=a,b<=x,並且a%b=0,a/b<x,a*b>x。

題解:

賽後發現,除開x=1的情況,其它情況a=b=x就可以滿足條件了...

但還是附上比賽時候的代碼吧...

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

int main(){
    int x;
    cin>>x;
    
for(int i=1;i<=x;i++){ for(int j=1;j<=i;j++){ if(i%j==0){ if(i*j>x && i/j<x){ printf("%d %d",i,j); return 0; } } } } cout<<"-1";
return 0; }

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