結果
| 問題 |
No.1136 Four Points Tour
|
| ユーザー |
bluemegane
|
| 提出日時 | 2021-05-19 15:59:25 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 32 ms / 2,000 ms |
| コード長 | 593 bytes |
| コンパイル時間 | 924 ms |
| コンパイル使用メモリ | 112,768 KB |
| 実行使用メモリ | 26,516 KB |
| 最終ジャッジ日時 | 2024-10-09 19:51:51 |
| 合計ジャッジ時間 | 3,536 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 41 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System.Numerics;
using System;
public class Hello
{
public static int MOD = 1000000007;
static void Main()
{
var n = long.Parse(Console.ReadLine().Trim());
getAns(n);
}
static void getAns(long n)
{
var ans = BigInteger.ModPow(3, n - 1, MOD);
if (n % 2 == 0) ans++;
else ans--;
ans *= 3;
ans %= MOD;
var inv4 = ModInverse(4, MOD);
ans *= inv4;
ans %= MOD;
Console.WriteLine(ans);
}
public static int ModInverse(int a, int m) => (int)BigInteger.ModPow(a, m - 2, m);
}
bluemegane