結果
| 問題 | No.1136 Four Points Tour |
| ユーザー |
bluemegane
|
| 提出日時 | 2021-05-19 15:59:25 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 28 ms / 2,000 ms |
| コード長 | 593 bytes |
| 記録 | |
| コンパイル時間 | 818 ms |
| コンパイル使用メモリ | 105,600 KB |
| 実行使用メモリ | 18,944 KB |
| 最終ジャッジ日時 | 2026-04-26 00:03:52 |
| 合計ジャッジ時間 | 3,175 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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