Lantern Festival

Link: https://ac.nowcoder.com/acm/contest/85/C
Source: Niuke

Title description
After all, it is the Lantern Festival, so I still have to eat a few Lantern Festival at night. Etéreo's family is a big family. The number of Lantern Festivals and even the number of tableware are amazing. Now, Etéreo, who loves mathematics, has come to ask you an interesting math problem again, let’s drop it in seconds! At Etéreo, there are \varsigmaς kinds of Yuanxiao fillings and \varthetaϑ kinds of Yuanxiao skins. You can choose any kind of Yuanxiao filling and any kind of Yuanxiao skin for each Lantern Festival. At the same time, there are \varpiϖ tables, and on each table are \varrhoϱ bowls, and each bowl can hold one Yuanxiao. Each bowl must contain a Yuanxiao. Etéreo will tell you the value of \varsigma, \vartheta, \varpi, \varrhoς,ϑ,ϖ,ϱ. I would like to ask you how many ways to install Lantern Festival. The answer is modulo \LambdaΛ.
The two methods are considered different if and only if there is at least one bowl in the same position of the two methods but there is at least one Yuanxiao in it.
Two Lantern Festivals are considered different if and only if the Lantern Festival fillings are different or the Lantern Festival skins are different.
Bowls and tables are numbered, but you cannot change the number of bowls or tables.
You can think that the bowl and table are fixed, you can only change the type and location of the Lantern Festival.

Input description:
input a line, five integers \varsigma, \vartheta, \varpi, \varrho, \Lambdaς,ϑ,ϖ,ϱ,Λ, the meaning is the same as the title description.
Output description:
One integer per line represents the answer.
Example 1
Input
Copy
1 2 1 3 998244353
Output
Copy
8
Remarks:
0 \leq \varsigma, \vartheta \leq 10^{18}0≤ς,ϑ≤10
18

0 \ leq \ varpi, \ varrho \ leq 10 ^ 60≤ϖ, ϱ≤10
6

1 \ leq \ Lambda \ leq 1,000,000,0071≤Λ≤1,000,000,007

There are so many choices for each seat.
If there is one, then there are 0 options.

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

#define int long long

using namespace std;

int qmi(int a, int b, int mod){
    
    
	int res = 1 % mod;
	while(b){
    
    
		if (b & 1)   res = res *  a % mod;
		a = a * a % mod;
		b >>= 1;
	}
	return res;
}

signed main(){
    
    
	//ios::sync_with_stdio(false);
    
	int a, b, c, d, mod;
	cin >> a >> b >> c >> d >> mod;
	
    a %= mod;
    b %= mod;
	int ans1 = a * b % mod;
	int ans2 = c * d;
	
	
//	cout << ans1 << "-------" << ans2 << endl;
	if (ans1 == 0 || ans2 == 0)   cout << "0" << endl;
	else{
    
    
		cout << qmi(ans1, ans2, mod) % mod << endl;
	} 
	
	return 0;
} 

Guess you like

Origin blog.csdn.net/qq_45772483/article/details/112596484