結果
問題 | No.747 循環小数N桁目 Hard |
ユーザー | sekiya9311 |
提出日時 | 2018-10-19 23:19:50 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
MLE
|
実行時間 | - |
コード長 | 7,926 bytes |
コンパイル時間 | 1,316 ms |
コンパイル使用メモリ | 111,872 KB |
実行使用メモリ | 1,387,048 KB |
最終ジャッジ日時 | 2024-11-18 22:37:28 |
合計ジャッジ時間 | 242,640 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 36 ms
24,832 KB |
testcase_01 | AC | 36 ms
334,976 KB |
testcase_02 | AC | 38 ms
24,576 KB |
testcase_03 | MLE | - |
testcase_04 | AC | 36 ms
24,832 KB |
testcase_05 | MLE | - |
testcase_06 | AC | 36 ms
24,832 KB |
testcase_07 | AC | 39 ms
137,968 KB |
testcase_08 | AC | 37 ms
24,832 KB |
testcase_09 | AC | 38 ms
393,316 KB |
testcase_10 | AC | 40 ms
24,704 KB |
testcase_11 | MLE | - |
testcase_12 | AC | 37 ms
24,832 KB |
testcase_13 | MLE | - |
testcase_14 | AC | 40 ms
24,960 KB |
testcase_15 | AC | 38 ms
34,848 KB |
testcase_16 | MLE | - |
testcase_17 | AC | 39 ms
24,704 KB |
testcase_18 | AC | 38 ms
77,812 KB |
testcase_19 | AC | 38 ms
24,576 KB |
testcase_20 | MLE | - |
testcase_21 | MLE | - |
testcase_22 | AC | 38 ms
24,960 KB |
testcase_23 | AC | 38 ms
24,832 KB |
testcase_24 | MLE | - |
testcase_25 | AC | 37 ms
24,832 KB |
testcase_26 | AC | 37 ms
67,420 KB |
testcase_27 | AC | 38 ms
24,704 KB |
testcase_28 | AC | 39 ms
67,132 KB |
testcase_29 | AC | 38 ms
24,576 KB |
testcase_30 | AC | 36 ms
67,208 KB |
testcase_31 | AC | 37 ms
24,704 KB |
testcase_32 | AC | 35 ms
67,388 KB |
testcase_33 | TLE | - |
testcase_34 | AC | 1,792 ms
497,096 KB |
testcase_35 | AC | 228 ms
69,760 KB |
testcase_36 | MLE | - |
testcase_37 | AC | 312 ms
72,192 KB |
testcase_38 | MLE | - |
testcase_39 | MLE | - |
testcase_40 | TLE | - |
testcase_41 | MLE | - |
testcase_42 | TLE | - |
testcase_43 | MLE | - |
testcase_44 | MLE | - |
testcase_45 | MLE | - |
testcase_46 | TLE | - |
testcase_47 | MLE | - |
testcase_48 | MLE | - |
testcase_49 | MLE | - |
testcase_50 | MLE | - |
testcase_51 | AC | 635 ms
170,228 KB |
testcase_52 | MLE | - |
testcase_53 | MLE | - |
testcase_54 | MLE | - |
testcase_55 | MLE | - |
testcase_56 | MLE | - |
testcase_57 | AC | 1,590 ms
421,396 KB |
testcase_58 | MLE | - |
testcase_59 | TLE | - |
testcase_60 | TLE | - |
testcase_61 | AC | 298 ms
109,220 KB |
testcase_62 | MLE | - |
testcase_63 | TLE | - |
testcase_64 | MLE | - |
testcase_65 | AC | 243 ms
94,940 KB |
testcase_66 | MLE | - |
testcase_67 | AC | 232 ms
78,096 KB |
testcase_68 | TLE | - |
testcase_69 | MLE | - |
testcase_70 | MLE | - |
testcase_71 | AC | 734 ms
176,336 KB |
testcase_72 | MLE | - |
testcase_73 | TLE | - |
testcase_74 | MLE | - |
testcase_75 | AC | 712 ms
231,256 KB |
testcase_76 | MLE | - |
testcase_77 | MLE | - |
testcase_78 | TLE | - |
testcase_79 | MLE | - |
testcase_80 | MLE | - |
testcase_81 | AC | 1,762 ms
488,584 KB |
testcase_82 | TLE | - |
testcase_83 | AC | 1,380 ms
421,844 KB |
testcase_84 | TLE | - |
testcase_85 | TLE | - |
testcase_86 | TLE | - |
testcase_87 | TLE | - |
testcase_88 | MLE | - |
testcase_89 | TLE | - |
testcase_90 | MLE | - |
testcase_91 | TLE | - |
testcase_92 | AC | 1,032 ms
346,500 KB |
testcase_93 | MLE | - |
testcase_94 | TLE | - |
testcase_95 | TLE | - |
testcase_96 | TLE | - |
testcase_97 | TLE | - |
testcase_98 | MLE | - |
testcase_99 | TLE | - |
testcase_100 | TLE | - |
testcase_101 | TLE | - |
testcase_102 | TLE | - |
testcase_103 | TLE | - |
testcase_104 | TLE | - |
testcase_105 | TLE | - |
testcase_106 | TLE | - |
testcase_107 | TLE | - |
testcase_108 | TLE | - |
testcase_109 | TLE | - |
testcase_110 | TLE | - |
testcase_111 | TLE | - |
testcase_112 | TLE | - |
testcase_113 | TLE | - |
testcase_114 | TLE | - |
testcase_115 | TLE | - |
testcase_116 | TLE | - |
testcase_117 | TLE | - |
testcase_118 | TLE | - |
testcase_119 | TLE | - |
testcase_120 | TLE | - |
testcase_121 | TLE | - |
testcase_122 | TLE | - |
testcase_123 | TLE | - |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; namespace ProgrammingContest { class Writer : IDisposable { private System.IO.TextWriter Out { get; } private StringBuilder Sb { get; } private bool IsReactive { get; } public Writer(string path) : this(new System.IO.StreamWriter(path)) { } public Writer(bool isReactive) : this(null, isReactive) { } public Writer(System.IO.TextWriter writer = null, bool isReactive = false) { this.Out = (writer ?? Console.Out); this.IsReactive = isReactive; if (!this.IsReactive) { this.Sb = new StringBuilder(); } } public void Dispose() { if (!this.IsReactive) { this.Out.Write(Sb.ToString()); } if (!this.Out.Equals(Console.Out)) { this.Out.Dispose(); } } public void Write(object val) { if (this.IsReactive) { this.Out.Write(val.ToString()); this.Out.Flush(); } else { this.Sb.Append(val.ToString()); } } public void WriteFormat(string format, params object[] vals) { if (this.IsReactive) { this.Out.Write(format, vals); this.Out.Flush(); } else { this.Sb.AppendFormat(format, vals); } } public void WriteLine(object val = null) { this.WriteFormat((val ?? string.Empty).ToString() + Environment.NewLine); } public void WriteLine(int val) { this.WriteLine(val.ToString()); } public void WriteLine(long val) { this.WriteLine(val.ToString()); } public void WriteLine(string val) { this.WriteLine((object)val); } public void WriteLine(string format, params object[] vals) { this.WriteFormat(format + Environment.NewLine, vals); } } class Scanner : IDisposable { private Queue<string> Buffer { get; } private char[] Sep { get; } private System.IO.TextReader Reader { get; } public Scanner(string path, char[] sep = null) : this(new System.IO.StreamReader(path), sep) { } public Scanner(System.IO.TextReader reader = null, char[] sep = null) { this.Buffer = new Queue<string>(); this.Sep = (sep ?? new char[] { ' ' }); this.Reader = (reader ?? Console.In); } private void CheckBuffer() { if (this.Buffer.Count == 0 && this.Reader.Peek() != -1) { string str = string.Empty; for (; string.IsNullOrEmpty(str) || string.IsNullOrWhiteSpace(str); str = this.Reader.ReadLine()) ; var strs = str.Split(this.Sep).Where(el => !(string.IsNullOrEmpty(el) || string.IsNullOrWhiteSpace(el))); foreach (var el in strs) { this.Buffer.Enqueue(el); } } } public void Dispose() { if (!this.Reader.Equals(Console.In)) { this.Reader.Dispose(); } } public string Next() { this.CheckBuffer(); return this.Buffer.Dequeue(); } public string[] GetStringArray(int N) { return Enumerable.Range(0, N) .Select(e => this.Next()) .ToArray(); } public int NextInt() { return int.Parse(this.Next()); } public int[] GetIntArray(int N) { return Enumerable.Range(0, N) .Select(e => this.NextInt()) .ToArray(); } public double NextDouble() { return double.Parse(this.Next()); } public double[] GetdoubleArray(int N) { return Enumerable.Range(0, N) .Select(e => this.NextDouble()) .ToArray(); } public long NextLong() { return long.Parse(this.Next()); } public long[] GetLongArray(int N) { return Enumerable.Range(0, N) .Select(e => this.NextLong()) .ToArray(); } public bool IsEnd { get { this.CheckBuffer(); return this.Buffer.Count == 0; } } } class MainClass : IDisposable { private Scanner Sc { get; } private Writer Wr { get; } static string BackPath { get; } = ".."; private char DirSep { get; } = System.IO.Path.DirectorySeparatorChar; private string InFilePath { get; } = string.Empty; private string OutFilePath { get; } = string.Empty; public MainClass() { this.InFilePath = MainClass.BackPath + this.DirSep + MainClass.BackPath + this.DirSep + "in.txt"; this.OutFilePath = MainClass.BackPath + this.DirSep + MainClass.BackPath + this.DirSep + "out.txt"; this.Wr = new Writer(this.IsReactive); //this.Wr = new Writer(this.OutFilePath); #if DEBUG if (!this.IsReactive) { this.Sc = new Scanner(this.InFilePath); } else { this.Sc = new Scanner(); } #else this.Sc = new Scanner(); #endif } static void Main(string[] args) { using (var mainClass = new MainClass()) { mainClass.Solve(); } } public void Dispose() { this.Sc?.Dispose(); this.Wr?.Dispose(); #if DEBUG Console.WriteLine("press any key to continue..."); Console.ReadKey(); #endif } int CalcMod(string val, int mod) => val .Select(c => c - '0') .Cast<int>() .Aggregate((a, b) => (a * 10 + b) % mod); int PowMod(int a, System.Numerics.BigInteger p, int mod) { if (p == System.Numerics.BigInteger.One) { return a; } else if (p == System.Numerics.BigInteger.Zero) { return 1; } else { if (p.IsEven) { var t = PowMod(a, p / 2, mod); return t * t % mod; } else { return a * PowMod(a, p - 1, mod) % mod; } } } void Solve() { string N = Sc.Next(); string K = Sc.Next(); const string V = "285714"; int nMod = CalcMod(N, V.Length); var idx = (PowMod(nMod, System.Numerics.BigInteger.Parse(K), V.Length) - 1 + V.Length) % V.Length; Wr.WriteLine(V[idx].ToString()); } private bool IsReactive { get; } = false; // TODO: reactive check !! } }