結果
問題 | No.2947 Sing a Song |
ユーザー |
|
提出日時 | 2024-10-25 21:55:22 |
言語 | C# (.NET 8.0.404) |
結果 |
AC
|
実行時間 | 98 ms / 2,000 ms |
コード長 | 2,146 bytes |
コンパイル時間 | 18,425 ms |
コンパイル使用メモリ | 168,092 KB |
実行使用メモリ | 199,056 KB |
最終ジャッジ日時 | 2024-10-25 21:55:46 |
合計ジャッジ時間 | 16,724 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 25 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (99 ms)。 MSBuild のバージョン 17.9.6+a4ecab324 (.NET) main -> /home/judge/data/code/bin/Release/net8.0/main.dll main -> /home/judge/data/code/bin/Release/net8.0/publish/
ソースコード
namespace AtCoder; #nullable enable using System.Numerics; static class Extensions { public static T[] Repeat<T>(this int time, Func<T> F) => Enumerable.Range(0, time).Select(_ => F()).ToArray(); } class AtCoder { object? Solve() { var n = Int(); var s = String(); var t = String(); var az = n.Repeat(Int); var sl = s.Length; var tl = t.Length; var max = az.Max(); var sc = (max + 1).Repeat(() => -1); for (var i = 0; i * tl <= max; i++) { if (sc[i * tl] >= 0) continue; var c = 0; for (var j = i * tl; j <= max; j += sl) sc[j] = c++; } foreach (var a in az) { var so = sc[a]; var to = (a - so * sl) / tl; var row = new List<string>(); for (var i = 0; i < so; i++) row.Add(s); for (var i = 0; i < to; i++) row.Add(t); Out(row, " "); } return null; } public static void Main() => new AtCoder().Run(); public void Run() { var res = Solve(); if (res != null) { if (res is bool yes) res = yes ? "Yes" : "No"; sw.WriteLine(res); } sw.Flush(); } string[] input = Array.Empty<string>(); int iter = 0; readonly StreamWriter sw = new(Console.OpenStandardOutput()) { AutoFlush = false }; string String() { while (iter >= input.Length) (input, iter) = (Console.ReadLine()!.Split(' '), 0); return input[iter++]; } T Input<T>() where T : IParsable<T> => T.Parse(String(), null); int Int() => Input<int>(); void Out(object? x, string? separator = null) { separator ??= Environment.NewLine; if (x is System.Collections.IEnumerable obj and not string) { var firstLine = true; foreach (var item in obj) { if (!firstLine) sw.Write(separator); firstLine = false; sw.Write(item); } } else sw.Write(x); sw.WriteLine(); } }