Atcoder060D数论

https://atcoder.jp/contests/arc060/tasks/arc060_b

分两种情况,b<=sqrt(n)直接枚举即可,b如果大于sqrt(n),必为两位数,设为pq,则p+q=s,pb+q=n,b=(n-s)/p+1,分解因数求解即可,注意判断n与s相等情况

#include
#include
#include
#include
#include
#define ll long long
const ll inf=1e12;
#define maxn 1000005
using namespace std;
ll n,s;
ll p[maxn];
ll cal(ll b,ll n)
{
    if(n

 

你可能感兴趣的:(数论)