結果
問題 | No.673 カブトムシ |
ユーザー | AreTrash |
提出日時 | 2018-05-04 19:43:50 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 28 ms / 2,000 ms |
コード長 | 3,895 bytes |
コンパイル時間 | 1,024 ms |
コンパイル使用メモリ | 114,652 KB |
実行使用メモリ | 25,916 KB |
最終ジャッジ日時 | 2024-06-30 06:38:57 |
合計ジャッジ時間 | 2,723 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 24 ms
23,932 KB |
testcase_01 | AC | 26 ms
24,108 KB |
testcase_02 | AC | 26 ms
25,792 KB |
testcase_03 | AC | 25 ms
23,736 KB |
testcase_04 | AC | 26 ms
21,684 KB |
testcase_05 | AC | 27 ms
23,936 KB |
testcase_06 | AC | 25 ms
23,812 KB |
testcase_07 | AC | 25 ms
21,940 KB |
testcase_08 | AC | 24 ms
23,744 KB |
testcase_09 | AC | 25 ms
23,936 KB |
testcase_10 | AC | 25 ms
23,676 KB |
testcase_11 | AC | 26 ms
23,940 KB |
testcase_12 | AC | 26 ms
23,808 KB |
testcase_13 | AC | 27 ms
23,932 KB |
testcase_14 | AC | 27 ms
24,000 KB |
testcase_15 | AC | 27 ms
24,064 KB |
testcase_16 | AC | 28 ms
25,916 KB |
testcase_17 | AC | 27 ms
23,872 KB |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; using System.IO; using System.Collections.Generic; namespace No673 { public class Program { void Solve(StreamScanner ss, StreamWriter sw) { //--------------------------------- var B = ss.Next(ModInt.Parse); var C = ss.Next(ModInt.Parse); var D = ss.Next(long.Parse); if (C.Value == 1) sw.WriteLine(B * D); else sw.WriteLine(B * C * (C.Pow(D) - 1) / (C - 1)); //--------------------------------- } static void Main() { var ss = new StreamScanner(new StreamReader(Console.OpenStandardInput())); var sw = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false}; new Program().Solve(ss, sw); sw.Flush(); } static readonly Func<string, string> String = s => s; } public struct ModInt { public static int Mod = 1000000007; readonly long value; public int Value { get { return (int)value; } } public ModInt Inverse { get { return GetInverse(); } } public ModInt(long value) { value %= Mod; this.value = value < 0 ? value + Mod : value; } ModInt GetInverse() { if (value == 0) throw new InvalidOperationException("value must NOT equal 0"); return Pow(Mod - 2); } public ModInt Square() { return this * this; } public ModInt Pow(long exp) { if (exp == 0) return 1; if (exp % 2 == 0) return Pow(exp / 2).Square(); return this * Pow(exp - 1); } public static ModInt Parse(string str) { return long.Parse(str); } public static implicit operator ModInt(long value) { return new ModInt(value); } public static ModInt operator +(ModInt left, ModInt right) { return left.value + right.value; } public static ModInt operator -(ModInt left, ModInt right) { return left.value - right.value; } public static ModInt operator *(ModInt left, ModInt right) { return left.value * right.value; } public static ModInt operator /(ModInt left, ModInt right) { return left * right.Inverse; } public override bool Equals(object obj) { if (!(obj is ModInt)) return false; return value == ((ModInt)obj).value; } public override int GetHashCode() { return value.GetHashCode(); } public override string ToString() { return value.ToString(); } } public class StreamScanner { static readonly char[] Sep = {' '}; readonly Queue<string> buffer = new Queue<string>(); readonly TextReader textReader; public StreamScanner(TextReader textReader) { this.textReader = textReader; } public T Next<T>(Func<string, T> parser) { if (buffer.Count != 0) return parser(buffer.Dequeue()); var nextStrings = textReader.ReadLine().Split(Sep, StringSplitOptions.RemoveEmptyEntries); foreach (var nextString in nextStrings) buffer.Enqueue(nextString); return Next(parser); } public T[] Next<T>(Func<string, T> parser, int x) { var ret = new T[x]; for (var i = 0; i < x; ++i) ret[i] = Next(parser); return ret; } public T[][] Next<T>(Func<string, T> parser, int x, int y) { var ret = new T[y][]; for (var i = 0; i < y; ++i) ret[i] = Next(parser, x); return ret; } } }