結果
問題 | No.3048 Swing |
ユーザー |
|
提出日時 | 2025-03-07 22:30:46 |
言語 | C# (.NET 8.0.404) |
結果 |
AC
|
実行時間 | 59 ms / 2,000 ms |
コード長 | 951 bytes |
コンパイル時間 | 7,307 ms |
コンパイル使用メモリ | 170,408 KB |
実行使用メモリ | 189,168 KB |
最終ジャッジ日時 | 2025-06-20 02:25:50 |
合計ジャッジ時間 | 12,415 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 62 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (104 ミリ秒)。 main -> /home/judge/data/code/bin/Release/net8.0/main.dll main -> /home/judge/data/code/bin/Release/net8.0/publish/
ソースコード
using System; using static System.Console; using System.Linq; using System.Collections.Generic; class Program { static int NN => int.Parse(ReadLine()); static long[] NList => ReadLine().Split().Select(long.Parse).ToArray(); public static void Main() { Solve(); } static void Solve() { var c = NList; var (x, n) = (c[0], c[1]); var ok = 0L; var ng = Math.Min(n, 1_500_000_000L) + 1; while (ng - ok > 1) { var mid = (ok + ng) / 2; if (mid * (mid + 1) / 2 > Math.Abs(x)) ng = mid; else ok = mid; } if (x <= 0) x += ok * (ok + 1) / 2; else x -= ok * (ok + 1) / 2; if (x <= 0) x -= (n - ok) / 2; else x += (n - ok) / 2; if ((n - ok) % 2 == 1) { if (x <= 0) x += n; else x -= n; } WriteLine(x); } }