結果

問題 No.1671 Permutation Tour
ユーザー Nitit JongsawatsatapornNitit Jongsawatsataporn
提出日時 2021-09-17 04:04:53
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 536 bytes
コンパイル時間 1,605 ms
コンパイル使用メモリ 165,352 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-12 04:18:07
合計ジャッジ時間 2,187 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
const int mod = 1e9+7;

int add(int a,int b) {
    int g = (a+b)%mod;
    if(g < 0)
        g += mod;
    return g;
}

int mul(int a, int b) {
    long long g = (1LL*a*b)%mod;
    return (int) g;
}

int power(int b, int p) {
    if(p == 0)
        return 1;
    
    int g = power(b,p/2);
    g = mul(g,g);
    if(p%2 == 1)
        g = mul(g,b);
    return g;
}

int inv(int b) {
    return power(b,mod-2);
}

int main() {
    int n; cin>>n;
    cout<<mul(n,mul(inv(3),n-1));
    return 0;
}
0