【题目链接】

点击打开链接

【算法】

我们知道,一个数的因子是成对出现的,一半小于等于sqrt(N),一半大于sqrt(N),因此,我们可以从

2..sqrt(N)枚举因子

【代码】

#include<bits/stdc++.h>
using namespace std;
#define MAX 3000000
typedef long long ll; ll i,l,n,k;
ll a[MAX+]; template <typename T> inline void read(T &x) {
int f = ; x = ;
char c = getchar();
for (; !isdigit(c); c = getchar()) { if (c == '-') f = -f; }
for (; isdigit(c); c = getchar()) x = x * + c - '';
x *= f;
} template <typename T> inline void write(T x) {
if (x < ) { putchar('-'); x = -x; }
if (x > ) write(x/);
putchar(x%+'');
} template <typename T> inline void writeln(T x) {
write(x);
puts("");
} int main() { read(n); read(k);
for (i = ; i <= sqrt(n); i++) {
if (!(n % i)) {
a[++l] = i;
if (i * i != n) a[++l] = n / i;
}
} sort(a+,a+l+); if (k <= l) writeln(a[k]);
else puts("-1"); return ; }

【Codeforces 762A】 k-th divisor的更多相关文章

  1. 【codeforces 762A】k-th divisor

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  2. 【codeforces 415D】Mashmokh and ACM(普通dp)

    [codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...

  3. 【codeforces 757B】 Bash's Big Day

    time limit per test2 seconds memory limit per test512 megabytes inputstandard input outputstandard o ...

  4. 【codeforces 755D】PolandBall and Polygon

    time limit per test4 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  5. 【codeforces 707E】Garlands

    [题目链接]:http://codeforces.com/contest/707/problem/E [题意] 给你一个n*m的方阵; 里面有k个联通块; 这k个联通块,每个连通块里面都是灯; 给你q ...

  6. 【codeforces 709C】Letters Cyclic Shift

    [题目链接]:http://codeforces.com/contest/709/problem/C [题意] 让你改变一个字符串的子集(连续的一段); ->这一段的每个字符的字母都变成之前的一 ...

  7. 【codeforces 515D】Drazil and Tiles

    [题目链接]:http://codeforces.com/contest/515/problem/D [题意] 给你一个n*m的格子; 然后让你用1*2的长方形去填格子的空缺; 如果有填满的方案且方案 ...

  8. 【codeforces 797E】Array Queries

    [题目链接]:http://codeforces.com/problemset/problem/797/E [题意] 给你一个n个元素的数组; 每个元素都在1..n之间; 然后给你q个询问; 每个询问 ...

  9. 【codeforces 801A】Vicious Keyboard

    [题目链接]:http://codeforces.com/contest/801/problem/A [题意] 一个字符串只由VK组成; 让你修改一个字符; 使得剩下的字符串里面子串VK的个数最大; ...

随机推荐

  1. 2017-10-29-morning-清北模拟赛

    T1 遭遇 #include <algorithm> #include <cstdio> #include <cmath> inline void read(int ...

  2. JQuery select 编程时选中原有的值

    js 此为核心代码 $(document).ready(function(){ $("#carTypeId").attr("value",'${carInfo. ...

  3. Spring的Bean定义

    以下内容引用自http://wiki.jikexueyuan.com/project/spring/bean-definition.html: Bean定义 被称作bean的对象是构成应用程序的支柱也 ...

  4. python把日期转换为秒数;日期转为字符串;datetime、date

    1.秒数是相对于1970.1.1号的秒数 2.日期的模块有time.datetime 3. import datetime t = datetime.datetime(2009, 10, 21, 0, ...

  5. myBatis学习笔记(10)——使用拦截器实现分页查询

    1. Page package com.sm.model; import java.util.List; public class Page<T> { public static fina ...

  6. C#-訪问轰炸机,新建进程,结束进程...(ConsoleApp)---ShinePans

    这个程序能够自己主动打开要打开的网址,而且自己主动结束进程,这样能够达到博文点击流量的添加 program.cs using System; using System.Collections.Gene ...

  7. 数据库系统学习(十)-嵌入式SQL语言之动态SQL

    第十讲 嵌入式SQL语言之动态SQL 静态SQL 区别变量和属性:高级语言向嵌入式SQL传递变量的方法 动态SQL 动态构造SQL语句是应用程序员必须掌握的重要手段 SQL语句的动态构造示例 根据界面 ...

  8. ubuntu compile php from source code

    10down vote Assuming that you already have the OpenSSL libraries and header files (on rpm systems th ...

  9. Microsoft Dynamics CRM Server 2013软件安装要求

    watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQveV9mMTIz/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/d ...

  10. MAC上Nuclide的安装

    MAC上Nuclide的安装 本文版权归作者全部,如需转载请联系孟祥月 CSDN博客:http://blog.csdn.net/mengxiangyue 独立博客:http://mengxiangyu ...