結果
| 問題 |
No.3331 Consecutive Cubic Sum
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-11-02 21:42:28 |
| 言語 | C# (.NET 8.0.404) |
| 結果 |
AC
|
| 実行時間 | 1,388 ms / 5,000 ms |
| コード長 | 1,040 bytes |
| コンパイル時間 | 18,288 ms |
| コンパイル使用メモリ | 169,996 KB |
| 実行使用メモリ | 190,976 KB |
| 最終ジャッジ日時 | 2025-11-02 21:44:03 |
| 合計ジャッジ時間 | 77,832 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge6 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 47 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (140 ミリ秒)。 main -> /home/judge/data/code/bin/Release/net8.0/main.dll main -> /home/judge/data/code/bin/Release/net8.0/publish/
ソースコード
#nullable enable
var n = Int128.Parse(Console.ReadLine()!);
var ans = new List<(Int128, Int128)>();
static Int128 F(Int128 l, Int128 d)
{
var r = l + d;
var ru = r * (r + 1);
var lu = l * (l + 1);
return ru * ru - lu * lu;
}
var m = n * 4;
var max = 200000;
for (Int128 l = 1; l <= max; l++)
{
Int128 pass = 0;
Int128 fail = int.MaxValue;
while (fail - pass > 1)
{
var mid = (pass + fail) >> 1;
if (F(l, mid) <= m) pass = mid;
else fail = mid;
}
if (F(l, pass) == m) ans.Add((l + 1, l + pass));
}
for (Int128 d = 1; d <= max; d++)
{
Int128 pass = 0;
Int128 fail = int.MaxValue;
while (fail - pass > 1)
{
var mid = (pass + fail) >> 1;
if (F(mid, d) <= m) pass = mid;
else fail = mid;
}
if (F(pass, d) == m) ans.Add((pass + 1, pass + d));
}
ans = ans.Distinct().ToList();
ans.Sort();
Console.WriteLine(ans.Count);
if (ans.Count > 0) Console.WriteLine(string.Join(Environment.NewLine, ans.Select(e => e.Item1 + " " + e.Item2)));