QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#641545#8339. Rooted Treezrj66TL 153ms3616kbC++201.3kb2024-10-14 21:03:282024-10-14 21:03:29

Judging History

你现在查看的是最新测评结果

  • [2024-10-14 21:03:29]
  • 评测
  • 测评结果:TL
  • 用时:153ms
  • 内存:3616kb
  • [2024-10-14 21:03:28]
  • 提交

answer

#include <bits/stdc++.h>

#define x first
#define y second
#define min(a, b) ((a) < (b)?(a):(b))
#define max(a, b) ((a) > (b)?(a):(b))

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL, LL> PLL; 
using PIII = pair<int, PII>;
using i128 = __int128;
using ULL = unsigned long long;

const int N = 10000100, M = 60010, MOD = 1e9 + 9, Base = 13331;
const int inf = 2e9, xf3 = 0x3f3f3f3f;
const LL INF = 4e18, XF3 = 0x3f3f3f3f3f3f3f3f;


LL n;
int K;
string s;
int infact[N];

LL qmi(LL a, LL b, LL p){
    i128 res = 1;
    while(b){
        if(b&1)res = res * a % p;
        b >>= 1;
        a = (i128)a * a % p;
    }
    return res;
}

void solve(){ 
    
    cin >> n >> K;
    int A = 0; 
    int ans = 0;
    for(int i = 0; i < K; i ++){
        int cnt = qmi((((n - 1LL) * (i)) + 1) % MOD, MOD - 2, MOD) % MOD;
        ans = (ans + (A * 1LL * cnt % MOD + 1) % MOD) % MOD;
        A = A * ((n - 1LL) * (i + 1) % MOD + 1) % MOD * cnt % MOD + n;
        A = A % MOD;
    }
    cout << ans * n % MOD << "\n";
    
    return;
}

int main(){
	
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0); 
	
	//cout<<fixed<<setprecision(0)<<"\n";
    int _ = 1;  
	// cin>>_;
	
	while(_ --){
		solve();
	} 
	
	return 0;
}

/*

*/

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3616kb

input:

6 2

output:

18

result:

ok 1 number(s): "18"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3520kb

input:

2 6

output:

600000038

result:

ok 1 number(s): "600000038"

Test #3:

score: 0
Accepted
time: 153ms
memory: 3548kb

input:

83 613210

output:

424200026

result:

ok 1 number(s): "424200026"

Test #4:

score: -100
Time Limit Exceeded

input:

48 6713156

output:


result: