提交记录 7072
提交时间 |
评测时间 |
2018-12-16 12:02:12 |
2020-08-01 00:57:55 |
#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 | 35.22 us | 36 KB | Accepted | Score: 5 | 显示更多 |
Testcase #2 | 40.78 us | 36 KB | Accepted | Score: 5 | 显示更多 |
Testcase #3 | 36.98 us | 36 KB | Accepted | Score: 5 | 显示更多 |
Testcase #4 | 35.59 us | 36 KB | Accepted | Score: 5 | 显示更多 |
Testcase #5 | 34.92 us | 36 KB | Accepted | Score: 5 | 显示更多 |
Testcase #6 | 35.5 us | 36 KB | Accepted | Score: 5 | 显示更多 |
Testcase #7 | 35.44 us | 36 KB | Accepted | Score: 5 | 显示更多 |
Testcase #8 | 34.88 us | 36 KB | Accepted | Score: 5 | 显示更多 |
Testcase #9 | 35.06 us | 36 KB | Accepted | Score: 5 | 显示更多 |
Testcase #10 | 34.83 us | 36 KB | Accepted | Score: 5 | 显示更多 |
Testcase #11 | 35.82 us | 36 KB | Accepted | Score: 5 | 显示更多 |
Testcase #12 | 35.16 us | 36 KB | Accepted | Score: 5 | 显示更多 |
Testcase #13 | 34.71 us | 36 KB | Accepted | Score: 5 | 显示更多 |
Testcase #14 | 35.56 us | 36 KB | Accepted | Score: 5 | 显示更多 |
Testcase #15 | 35.29 us | 36 KB | Accepted | Score: 5 | 显示更多 |
Testcase #16 | 36.1 us | 36 KB | Accepted | Score: 5 | 显示更多 |
Testcase #17 | 35.75 us | 36 KB | Accepted | Score: 5 | 显示更多 |
Testcase #18 | 42.55 us | 36 KB | Accepted | Score: 5 | 显示更多 |
Testcase #19 | 37.9 us | 36 KB | Accepted | Score: 5 | 显示更多 |
Testcase #20 | 35.82 us | 36 KB | Accepted | Score: 5 | 显示更多 |
Judge Duck Online | 评测鸭在线
Server Time: 2024-12-05 10:09:05 | Loaded in 2 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠