結果

問題 No.1136 Four Points Tour
ユーザー NoviNovi
提出日時 2020-08-22 20:41:42
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 101 ms / 2,000 ms
コード長 919 bytes
コンパイル時間 1,926 ms
コンパイル使用メモリ 164,496 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2024-04-23 12:22:56
合計ジャッジ時間 9,030 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 45 ms
6,784 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 70 ms
8,576 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 10 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 9 ms
5,376 KB
testcase_15 AC 3 ms
5,376 KB
testcase_16 AC 9 ms
5,376 KB
testcase_17 AC 11 ms
5,376 KB
testcase_18 AC 53 ms
7,468 KB
testcase_19 AC 101 ms
11,008 KB
testcase_20 AC 5 ms
5,376 KB
testcase_21 AC 54 ms
7,424 KB
01_Sample03_evil.txt RE -
04_Rnd_large_evil1.txt RE -
04_Rnd_large_evil2.txt RE -
04_Rnd_large_evil3.txt RE -
04_Rnd_large_evil4.txt MLE -
04_Rnd_large_evil5.txt RE -
04_Rnd_large_evil6.txt RE -
04_Rnd_large_evil7.txt RE -
04_Rnd_large_evil8.txt MLE -
04_Rnd_large_evil9.txt RE -
04_Rnd_large_evil10.txt MLE -
05_Rnd_huge_evil1.txt RE -
05_Rnd_huge_evil2.txt RE -
05_Rnd_huge_evil3.txt RE -
05_Rnd_huge_evil4.txt RE -
05_Rnd_huge_evil5.txt RE -
05_Rnd_huge_evil6.txt RE -
05_Rnd_huge_evil7.txt RE -
99_evil_01.txt RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;
typedef pair<int, int> pint;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    Int n; cin>>n;
    Int mod=1000000007;
    vector<Int> dp(n+1,0);
    dp[0]=1;dp[1]=0; dp[2]=3;
    for(int i=2; i<n; i++){
        dp[i+1]=modpow(3,i,mod)-dp[i]%mod;
        dp[i+1]%=mod;
        if(dp[i+1]<0) dp[i+1]+=mod;
    }
    cout<<dp[n]<<endl;
    return 0;
}
0