提交记录 16389


用户 题目 状态 得分 用时 内存 语言 代码长度
jzy noip18e. 【NOIP2018】填数游戏 Accepted 100 41.36 us 36 KB C++ 1.05 KB
提交时间 评测时间
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;
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #134.96 us36 KBAcceptedScore: 5

Testcase #241.36 us36 KBAcceptedScore: 5

Testcase #337.3 us36 KBAcceptedScore: 5

Testcase #434.6 us36 KBAcceptedScore: 5

Testcase #540.55 us36 KBAcceptedScore: 5

Testcase #634.82 us36 KBAcceptedScore: 5

Testcase #736.44 us36 KBAcceptedScore: 5

Testcase #835.21 us36 KBAcceptedScore: 5

Testcase #934.63 us36 KBAcceptedScore: 5

Testcase #1034.62 us36 KBAcceptedScore: 5

Testcase #1135.5 us36 KBAcceptedScore: 5

Testcase #1234.9 us36 KBAcceptedScore: 5

Testcase #1334.49 us36 KBAcceptedScore: 5

Testcase #1435.81 us36 KBAcceptedScore: 5

Testcase #1537.03 us36 KBAcceptedScore: 5

Testcase #1636.15 us36 KBAcceptedScore: 5

Testcase #1736.1 us36 KBAcceptedScore: 5

Testcase #1836.02 us36 KBAcceptedScore: 5

Testcase #1935.28 us36 KBAcceptedScore: 5

Testcase #2035.26 us36 KBAcceptedScore: 5


Judge Duck Online | 评测鸭在线
Server Time: 2024-12-05 10:08:15 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠