結果

問題 No.1659 Product of Divisors
ユーザー inksamuraiinksamurai
提出日時 2021-08-27 22:30:13
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 550 ms / 2,000 ms
コード長 2,868 bytes
コンパイル時間 2,387 ms
コンパイル使用メモリ 108,368 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-13 09:38:49
合計ジャッジ時間 4,282 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 2 ms
4,384 KB
testcase_03 AC 2 ms
4,384 KB
testcase_04 AC 39 ms
4,384 KB
testcase_05 AC 125 ms
4,384 KB
testcase_06 AC 3 ms
4,380 KB
testcase_07 AC 2 ms
4,384 KB
testcase_08 AC 81 ms
4,380 KB
testcase_09 AC 81 ms
4,380 KB
testcase_10 AC 29 ms
4,384 KB
testcase_11 AC 80 ms
4,384 KB
testcase_12 AC 548 ms
4,384 KB
testcase_13 AC 2 ms
4,384 KB
testcase_14 AC 550 ms
4,380 KB
testcase_15 AC 3 ms
4,384 KB
testcase_16 AC 3 ms
4,384 KB
testcase_17 AC 3 ms
4,384 KB
testcase_18 AC 4 ms
4,380 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 20 ms
4,384 KB
testcase_21 AC 19 ms
4,380 KB
testcase_22 AC 18 ms
4,384 KB
testcase_23 AC 56 ms
4,384 KB
testcase_24 AC 16 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cmath>
#include <deque>
#include <algorithm>
#include <iterator>
#include <list>
#include <tuple>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <unordered_set>
#include <stack>
#include <string>
#include <vector>
#include <fstream>
#include <iostream>
#include <functional>
#include <numeric>
#include <iomanip> 
#include <stdio.h>
#include <assert.h>
#include <cstring>
//eolibraries
#define lnf 3999999999999999999
#define inf 999999999
#define fi first
#define se second
#define pb push_back
#define ll long long
#define ld long double
#define all(c) (c).begin(),(c).end()
#define sz(c) (int)(c).size()
#define make_unique(a) sort(all(a)),a.erase(unique(all(a)),a.end());
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;i>=0;i--)
#define crep(i,x,n) for(int i=x;i<n;i++)
#define vec(...) vector<__VA_ARGS__>
#define _3kynfAJ ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
//eodefine
using namespace std;
using pii=pair<int,int>;
using vi=vec(int);
const int mxn=13345;

//snuke's modular int
template <ll mod>
struct modularint{
	ll x;
	modularint(ll x=0):x(x%mod){}
	modularint& operator+=(const modularint a){
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	modularint& operator-=(const modularint a){
		if ((x += mod-a.x) >= mod) x -= mod;
		return *this;
	}
	modularint& operator*=(const modularint a){
		(x *= a.x) %= mod;
		return *this;
	}
	modularint operator+(const modularint a)const{
		modularint res(*this);
		return res+=a;
	}
	modularint operator-(const modularint a)const{
		modularint res(*this);
		return res-=a;
	}
	modularint operator*(const modularint a)const{
		modularint res(*this);
		return res*=a;
	}
	modularint pow(ll n)const{
		modularint res=1,x(*this);
		while(n){
			if(n&1)res*=x;
			x*=x;
			n>>=1;
		}
		return res;
	}
	modularint inv()const{
		return pow(mod-2);
	}
};
using mint=modularint<1000000007>;

mint fact[mxn+10];
void prefact(){
fact[0]=fact[1]=1;
  crep(i,2,mxn){
    mint x=i;
    fact[i]=fact[i-1]*x;
  }
}

mint slocnk(ll k,ll n){
  if(k>n) return 0;
  mint e=1,d=(n-k);
  while(n>k){
  	e*=n;
  	n=n-1;
  }
  while(d.x>0){
  	e*=d.inv();
  	d.x=d.x-1;
  }
  return e;
}

int main(){
_3kynfAJ;
// prefact();
	ll n,k;
	cin>>n>>k;
	vec(ll) dvs;
	for(ll x=1;x<=sqrt(n);x++){
		if(n%x==0){
			dvs.pb(x);
			dvs.pb(n/x);
		}
	}
	make_unique(dvs);

	// auto g=[&](ll cnt)->{
	// 	mint e=cnk(k-1,cnt+k-1);
	// 	ans+=e;
	// };
	mint ans=0;

	auto f=[&](ll n)->void{
		ll y=n;
		mint now=1;
		for(ll x=2;x<=sqrt(y);x++){
			ll cnt=0;
			while(n%x==0){
				n/=x;
				cnt++;
			}
			if(cnt){
				// cout<<cnk(k-1,cnt+k-1).x<<"\n";
				mint e=slocnk(k-1,cnt+k-1);
				now*=e;
			}
		}
		if(n!=1){
			mint e=slocnk(k-1,k);
			now*=e;
		}
		// cout<<now.x<<"\n";
		ans+=now;
	};

	for(auto x : dvs){
		f(x);
	}
	cout<<ans.x<<"\n";
//
	return 0;
}
0