static void Main() { var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; var sc = new Scan(); var mt = new mymath(); var inp = sc.LongArr; long a = inp[0], b = inp[1]; int m = (int)inp[2]; long g = mt.gcd(a, b); var ini = new long[] { 1, 1 }; sw.WriteLine(mt.mulmat(mt.powmat(new long[][] { new long[] { 10, 1 }, new long[] { 0, 1 } }, a - 1, m), ini, m)[0] * mt.mulmat(mt.powmat(new long[][] { new long[] { mt.powmod(10, g, m), 1 }, new long[] { 0, 1 } }, b / g - 1, m), ini, m)[0] % m); sw.Flush(); }
static void Main() { var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; var sc = new Scan(); int n, a, b; sc.Multi(out n, out a, out b); var inp = sc.LongArr; Array.Sort(inp); var ar = copy(inp); if (a == 1) { foreach (var item in ar) { sw.WriteLine(item); } sw.Flush(); return; } int c = 0; for (int i = 0; i < n; i++) { while (ar[i] * a <= ar[n - 1]) { ar[i] *= a; ++c; } } Array.Sort(ar); if (c > b) { ar = copy(inp); for (int i = 0; i < b; i++) { ar[0] *= a; Array.Sort(ar); } foreach (var item in ar) { sw.WriteLine(item); } sw.Flush(); return; } b -= c; int ba = b / n, bb = b % n; var arr = new long[n]; var mt = new mymath(); for (int i = 0; i < n - bb; i++) { arr[i] = ar[i + bb] * mt.powmod(a, ba, M) % M; } for (int i = n - bb; i < n; i++) { arr[i] = ar[i + bb - n] * mt.powmod(a, ba + 1, M) % M; } foreach (var item in arr) { sw.WriteLine(item); } sw.Flush(); }