提交记录 16389
提交时间 |
评测时间 |
2021-07-25 20:05:56 |
2021-07-25 20:07:21 |
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC optimize(3)
#include<bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int f_pow(int A,int B){
int ans = 1;
for( ;B; B >>= 1 ){
if( B & 1 )ans = 1ll * ans * A % mod;
A = 1ll * A * A % mod;
}
return ans;
}
int main(){
int n,m;cin >> n >> m;
if( n > m )swap( n,m );
if( n == 1 )return cout << f_pow( 2,m ),0;
if( n == 2 )return cout << 4ll * f_pow( 3,m - 1 ) % mod,0;
if( n == 3 )return cout << 112ll * f_pow( 3,m - 3 ) % mod,0;
int ans1 = 1ll * f_pow( 4,n - 2 ) * f_pow( 2,n ) % mod;
int ans2 = 5ll * f_pow( 4,n - 4 ) * f_pow( 2,n ) % mod;
int ans3 = 20ll * f_pow( 2,n ) % mod * (f_pow( 4,n - 4 ) - 1) % mod * (mod + 1)/3 % mod;
ans3 = ( ans3 + 15ll * f_pow( 2,n - 1 ) ) % mod;
int ans = ( (ans1 + ans2) % mod + ans3 ) % mod * 2 % mod;
if( n == m )return cout << ans,0;
ans = 3ll * ( ans - f_pow( 2,n ) ) % mod;
ans = 1ll * ans * f_pow( 3,m - n - 1 ) % mod;
ans = ( ans + mod ) % mod;
cout << ans;
return 0;
}
Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
Testcase #1 | 34.96 us | 36 KB | Accepted | Score: 5 | 显示更多 |
Testcase #2 | 41.36 us | 36 KB | Accepted | Score: 5 | 显示更多 |
Testcase #3 | 37.3 us | 36 KB | Accepted | Score: 5 | 显示更多 |
Testcase #4 | 34.6 us | 36 KB | Accepted | Score: 5 | 显示更多 |
Testcase #5 | 40.55 us | 36 KB | Accepted | Score: 5 | 显示更多 |
Testcase #6 | 34.82 us | 36 KB | Accepted | Score: 5 | 显示更多 |
Testcase #7 | 36.44 us | 36 KB | Accepted | Score: 5 | 显示更多 |
Testcase #8 | 35.21 us | 36 KB | Accepted | Score: 5 | 显示更多 |
Testcase #9 | 34.63 us | 36 KB | Accepted | Score: 5 | 显示更多 |
Testcase #10 | 34.62 us | 36 KB | Accepted | Score: 5 | 显示更多 |
Testcase #11 | 35.5 us | 36 KB | Accepted | Score: 5 | 显示更多 |
Testcase #12 | 34.9 us | 36 KB | Accepted | Score: 5 | 显示更多 |
Testcase #13 | 34.49 us | 36 KB | Accepted | Score: 5 | 显示更多 |
Testcase #14 | 35.81 us | 36 KB | Accepted | Score: 5 | 显示更多 |
Testcase #15 | 37.03 us | 36 KB | Accepted | Score: 5 | 显示更多 |
Testcase #16 | 36.15 us | 36 KB | Accepted | Score: 5 | 显示更多 |
Testcase #17 | 36.1 us | 36 KB | Accepted | Score: 5 | 显示更多 |
Testcase #18 | 36.02 us | 36 KB | Accepted | Score: 5 | 显示更多 |
Testcase #19 | 35.28 us | 36 KB | Accepted | Score: 5 | 显示更多 |
Testcase #20 | 35.26 us | 36 KB | Accepted | Score: 5 | 显示更多 |
Judge Duck Online | 评测鸭在线
Server Time: 2024-12-05 10:08:15 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠