# Tag-数学

Icontofig 's Blog // 我们的征程是星辰大海！Away From OI，Come to ICPC（查看友链请点About Me）

2019-11-06 22:11:12 |  0 Comments  |  数论 数学

## 代码

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll get_num(){
ll num = 0;
char c;
bool flag = false;
while((c = getchar()) == ' ' || c == '\r' || c == '\n');
if(c == '-')
flag = true;
else num = c - '0';
while(isdigit(c = getchar()))
num = (num << 3) + (num << 1) + c - '0';
return (flag ? -1 : 1) * num;
}
ll y,z,p;
map<ll,ll>mp;
ll quick_pow(ll a,ll b,ll mod){
ll ret = 1;
while(b > 0){
if(b & 1){
ret = ret * a;
ret %= mod;
}
b >>= 1;
a = a * a;
a %= mod;
}
return ret;
}
void exgcd(ll a,ll b,ll &d,ll &x,ll &y){
if(b == 0){
d = a;
x = 1;
y = 0;
return;
}
exgcd(b,a%b,d,x,y);
ll tp = x;
x = y;
y = tp - (a / b) * y;
return;
}
void BSGS(ll y,ll z,ll p){
mp.clear();
y %= p;
if(y == 0 && z == 0){
cout << "1" 

## 题解

So……这时候我们就用到容斥原理了。假设$an{s}_{i}$$ans_i$为恰好i种颜色都恰好出现k次,由容斥原理有：
$an{s}_{i}=\sum _{j=i}^{min\left(m,n/S\right)}{\left(-1\right)}^{j-i}\ast {C}_{j}^{i}\ast {f}_{j}\ast j！$$ans_i = \sum_{j=i}^{min(m,$

#include <bits/stdc++.h>
using namespace std;
int n,m,s;
const int maxm = 1e5+5;
const int maxn = 1e7+5;
typedef long long ll;
const ll mod = 1004535809;
ll fac[maxn],inv[maxn],w[maxm],f[maxm<<2],finv[maxn];
ll b[maxm<<2];
int rev[maxm<<2];
void init(int x){
fac[0] = fac[1] = inv[0] = inv[1] = finv[0] = finv[1] = 1ll;
for(int i = 2;i <= x;++i){
fac[i] = fac[i-1] * i % mod;
inv[i] = (mod - mod / i) * inv[mod % i] % mod;
finv[i] = finv[i-1] * inv[i] % mod;
}
return;
}
ll quick_pow(ll a,ll b,ll mod){
ll ret = 1;
while(b){
if(b & 1)
ret = (ret * a) % mod;
a = (a * a) % mod;
b >>= 1;
}
return ret;
}
ll g;
int len,lg;
void NTT_init(int k){
len = 1;lg = 0;
for(len = 1;len < k;len <<= 1,lg++);
for(int i = 0;i < len;++i)
rev[i] = (rev[i>>1]>>1) | ((i & 1) << (lg - 1));
}
void NTT(ll *a,int len,int f){
for(int i = 0;i < len;++i){
if(i < rev[i])
swap(a[i],a[rev[i
2017-01-31 21:35:39 |  1 Comments  |  模拟 数学

# A. k-th divisor

You are given two integers n and k. Find k-th smallest divisor of n, or report that it doesn't exist.

Divisor of n is any such natural number, that n can be divided by it without remainder.

Input

The first line contains two integers n and k (1 ≤ n ≤ 10151 ≤ k ≤ 109).

Output

If n has less than k divisors, output -1.

Otherwise, output the k-th smallest divisor of n.

Examples
input
4 2
output
2
input
5 3
output
-1
input
12 5
output
6
Note

In the first example, number 4 has three divisors: 12 and 4. The second one is 2.

In the second example, number 5 has only two divisors: 1 and 5. The third divisor doesn't exist, so the answer is -1.

#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <vector>
using namespace s
Title - Artist
0:00