結果
問題 |
No.1136 Four Points Tour
|
ユーザー |
![]() |
提出日時 | 2021-05-19 15:52:35 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 30 ms / 2,000 ms |
コード長 | 634 bytes |
コンパイル時間 | 971 ms |
コンパイル使用メモリ | 111,012 KB |
実行使用メモリ | 26,384 KB |
最終ジャッジ日時 | 2024-10-09 19:46:11 |
合計ジャッジ時間 | 3,406 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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 BigInteger ModInverse(BigInteger a, BigInteger m) { return BigInteger.ModPow(a, m - 2, m); } }