結果
| 問題 | No.800 四平方定理 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-04-13 14:16:16 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 158 ms / 2,000 ms |
| コード長 | 1,785 bytes |
| 記録 | |
| コンパイル時間 | 1,216 ms |
| コンパイル使用メモリ | 107,264 KB |
| 実行使用メモリ | 47,744 KB |
| 最終ジャッジ日時 | 2024-09-15 11:05:20 |
| 合計ジャッジ時間 | 5,099 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 |
コンパイルメッセージ
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.Generic;
using System.Linq;
using static Input;
public class Prog
{
private const int INF = 1000000007;
private const long INFINITY = 9223372036854775807;
private struct Pair { public int x, y; }
public static void Main()
{
int N = NextInt();
int D = NextInt();
int[] memo1 = new int[8000010];
for (int x = 1; x <= N; x++)
for (int y = 1; y <= N; y++)
memo1[x * x + y * y]++;
long ans = 0;
for (int z = 1; z <= N; z++)
for (int w = 1; w <= N; w++)
{
if (w * w - z * z + D < 0) continue;
ans += memo1[(w * w - z * z + D)];
}
Console.WriteLine(ans);
}
}
public class Input
{
private static Queue<string> q = new Queue<string>();
private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
public static char NextChar() { Confirm(); return char.Parse(q.Dequeue()); }
public static string NextString() { Confirm(); return q.Dequeue(); }
public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}