提交记录 7072


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

CompilationN/AN/ACompile OKScore: N/A

Testcase #135.22 us36 KBAcceptedScore: 5

Testcase #240.78 us36 KBAcceptedScore: 5

Testcase #336.98 us36 KBAcceptedScore: 5

Testcase #435.59 us36 KBAcceptedScore: 5

Testcase #534.92 us36 KBAcceptedScore: 5

Testcase #635.5 us36 KBAcceptedScore: 5

Testcase #735.44 us36 KBAcceptedScore: 5

Testcase #834.88 us36 KBAcceptedScore: 5

Testcase #935.06 us36 KBAcceptedScore: 5

Testcase #1034.83 us36 KBAcceptedScore: 5

Testcase #1135.82 us36 KBAcceptedScore: 5

Testcase #1235.16 us36 KBAcceptedScore: 5

Testcase #1334.71 us36 KBAcceptedScore: 5

Testcase #1435.56 us36 KBAcceptedScore: 5

Testcase #1535.29 us36 KBAcceptedScore: 5

Testcase #1636.1 us36 KBAcceptedScore: 5

Testcase #1735.75 us36 KBAcceptedScore: 5

Testcase #1842.55 us36 KBAcceptedScore: 5

Testcase #1937.9 us36 KBAcceptedScore: 5

Testcase #2035.82 us36 KBAcceptedScore: 5


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