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

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;
}

原文地址:https://www.cnblogs.com/heyuhhh/p/10073988.html

时间: 2024-11-09 03:07:12

Codeforces Round #525 (Div. 2)A. Ehab and another construction problem的相关文章

Codeforces Round #525 (Div. 2)

Codeforces Round #525 (Div. 2) glhf T1: 题意:求两个数\(a,b\)使\(1<=a,b<=n\),\(a\)%\(b==0\),\(a/b<n\),\(a*b>n\) \(n<=100\) 当时直接打了暴力 #include<map> #include<queue> #include<cmath> #include<bitset> #include<cstdio> #inclu

Codeforces Round #261 (Div. 2) D. Pashmak and Parmida&#39;s problem (树状数组求逆序数 变形)

题目链接 题意: 给出一些数a[n],求(i, j), i<j 的数量,使得:f(1, i, a[i]) > f(j, n, a[j]) . f(lhs, rhs, x) 指在 { [lhs, rhs]范围中,a[k]的值=x } 的数量. 1.  f(1, i, a[i]) 就是指a[i]前面包括a[i]的数中,有几个值=a[i]. 2.  f(j, n, a[j]) 就是指a[j]后面包括a[j]的数中有几个值=a[j]. 虽然a[x]范围不小,但是n的范围是1000,不是很大,所以我们可

Codeforces Round #261 (Div. 2)459D. Pashmak and Parmida&#39;s problem(求逆序数对)

题目链接:http://codeforces.com/contest/459/problem/D D. Pashmak and Parmida's problem time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output Parmida is a clever girl and she wants to participate in O

Codeforces Round #261 (Div. 2) D. Pashmak and Parmida&#39;s problem (树状数组)

D. Pashmak and Parmida's problem time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output Parmida is a clever girl and she wants to participate in Olympiads this year. Of course she wants her partn

Codeforces Round 261 Div.2 D Pashmak and Parmida&#39;s problem --树状数组

题意:给出数组A,定义f(l,r,x)为A[]的下标l到r之间,等于x的元素数.i和j符合f(1,i,a[i])>f(j,n,a[j]),求有多少对这样的(i,j). 解法:分别从左到右,由右到左预处理到某个下标为止有多少个数等于该下标,用map维护. 然后树状数组更新每个f(j,n,a[j]),预处理完毕,接下来,从左往右扫过去,每次从树状数组中删去a[i],因为i != j,i不能用作后面的统计,然后统计getsum(inc[a[i]]-1), (inc表示从左到右),即查询比此时的a[i]

Codeforces Round #563 (Div. 2)C. Ehab and a Special Coloring Problem

原文链接:传送门思路:素数筛代码: 1 #include"iostream" 2 #include"algorithm" 3 #include"cstring" 4 using namespace std; 5 long long a[2000006],n; 6 int main(){ 7 cin>>n; 8 long long flag = 1; 9 memset(a,0,sizeof(a)); 10 for(int i=2;i&l

Codeforces Round #563 (Div. 2)B;Ehab Is an Odd Person

原文链接:任意门 题目大意:给你一组数,让你交换两个数的位置,让它们的和为奇数,且使其交换后,顺序满足最小字典序列.思路:这就是一道狗题,看代码,你就会******了,只需要sort排序.代码: 1 #include"iostream" 2 #include"algorithm" 3 #include"cstdio" 4 #include"cstring" 5 long long a[10000006],n,js=0,os=0

Codeforces Round #428 (Div. 2)

Codeforces Round #428 (Div. 2) A    看懂题目意思就知道做了 #include<bits/stdc++.h> using namespace std; #pragma comment(linker, "/STACK:102400000,102400000") #define rep(i,a,b) for (int i=a; i<=b; ++i) #define per(i,b,a) for (int i=b; i>=a; --i

Codeforces Round #424 (Div. 2) D. Office Keys(dp)

题目链接:Codeforces Round #424 (Div. 2) D. Office Keys 题意: 在一条轴上有n个人,和m个钥匙,门在s位置. 现在每个人走单位距离需要单位时间. 每个钥匙只能被一个人拿. 求全部的人拿到钥匙并且走到门的最短时间. 题解: 显然没有交叉的情况,因为如果交叉的话可能不是最优解. 然后考虑dp[i][j]表示第i个人拿了第j把钥匙,然后 dp[i][j]=max(val(i,j),min(dp[i-1][i-1~j]))   val(i,j)表示第i个人拿