QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#440007#8339. Rooted Treeucup-team1074#WA 1436ms6872kbC++231.4kb2024-06-12 22:49:262024-06-12 22:49:27

Judging History

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

  • [2024-06-12 22:49:27]
  • 评测
  • 测评结果:WA
  • 用时:1436ms
  • 内存:6872kb
  • [2024-06-12 22:49:26]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define pb push_back
#define x first
#define y second 
#define endl '\n'
const LL maxn = 4e05+7;
const LL N = 5e05+10;
const LL mod = 1e09+9;
const int inf = 0x3f3f3f3f;
const LL llinf = 5e18;
#define int long long
typedef pair<int,int>pl;
priority_queue<LL , vector<LL>, greater<LL> >mi;//小根堆
priority_queue<LL> ma;//大根堆
LL gcd(LL a, LL b){
	return b > 0 ? gcd(b , a % b) : a;
}

LL lcm(LL a , LL b){
	return a / gcd(a , b) * b;
}
int n , m;
vector<int>a(N , 0);
void init(int n){
	for(int i = 0 ; i <= n ; i ++){
		a[i] = 0;
	}
}
LL qpow(LL a , LL b)//快速幂
{
	LL sum=1;
	while(b){
		if(b&1){
			sum=sum*a%mod;
		}
		a=a*a%mod;
		b>>=1;
	}
	return sum;
}
void solve() 
{
	int m , k;
	int pre = 0;
	int tot = 1;
	cin >> m >> k;
	int ans = 0;
	for(int i = 0 ; i < k ; i ++){
		int choi = pre * qpow(tot , mod - 2);
		choi %= mod;
		ans += choi;
		ans %= mod;
		int add = m * (choi + tot * qpow(tot , mod - 2));
		add %= mod;
		pre -= choi;
		pre += add;
		pre += mod * 4;
		pre %= mod;
		tot += m - 1;
		tot %= mod;
	}
	cout << (ans + pre) % mod;
}            
signed main() 
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(10);
    int t=1;
	//cin>>t;
    while(t--)
    {
    	solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

6 2

output:

18

result:

ok 1 number(s): "18"

Test #2:

score: 0
Accepted
time: 2ms
memory: 6872kb

input:

2 6

output:

600000038

result:

ok 1 number(s): "600000038"

Test #3:

score: 0
Accepted
time: 133ms
memory: 6804kb

input:

83 613210

output:

424200026

result:

ok 1 number(s): "424200026"

Test #4:

score: -100
Wrong Answer
time: 1436ms
memory: 6820kb

input:

48 6713156

output:

173796836

result:

wrong answer 1st numbers differ - expected: '198541581', found: '173796836'