結果
問題 |
No.1136 Four Points Tour
|
ユーザー |
![]() |
提出日時 | 2021-05-19 16:01:34 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 26 ms / 2,000 ms |
コード長 | 601 bytes |
コンパイル時間 | 889 ms |
コンパイル使用メモリ | 112,604 KB |
実行使用メモリ | 26,204 KB |
最終ジャッジ日時 | 2024-10-09 19:54:33 |
合計ジャッジ時間 | 3,093 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 = (long) BigInteger.ModPow(3, n - 1, MOD); if (n % 2 == 0) ans++; else ans--; ans *= 3L; 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); }