結果
問題 | No.800 四平方定理 |
ユーザー | mban |
提出日時 | 2019-03-18 06:34:25 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 175 ms / 2,000 ms |
コード長 | 11,251 bytes |
コンパイル時間 | 1,654 ms |
コンパイル使用メモリ | 114,804 KB |
実行使用メモリ | 54,572 KB |
最終ジャッジ日時 | 2024-07-16 01:17:40 |
合計ジャッジ時間 | 4,400 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 26 ms
26,104 KB |
testcase_01 | AC | 27 ms
23,924 KB |
testcase_02 | AC | 26 ms
23,796 KB |
testcase_03 | AC | 27 ms
23,800 KB |
testcase_04 | AC | 28 ms
26,096 KB |
testcase_05 | AC | 29 ms
25,968 KB |
testcase_06 | AC | 27 ms
24,052 KB |
testcase_07 | AC | 27 ms
24,044 KB |
testcase_08 | AC | 27 ms
24,052 KB |
testcase_09 | AC | 28 ms
24,052 KB |
testcase_10 | AC | 73 ms
40,532 KB |
testcase_11 | AC | 82 ms
42,716 KB |
testcase_12 | AC | 83 ms
40,368 KB |
testcase_13 | AC | 76 ms
41,428 KB |
testcase_14 | AC | 82 ms
40,448 KB |
testcase_15 | AC | 79 ms
40,292 KB |
testcase_16 | AC | 88 ms
42,808 KB |
testcase_17 | AC | 85 ms
40,928 KB |
testcase_18 | AC | 90 ms
41,004 KB |
testcase_19 | AC | 86 ms
42,636 KB |
testcase_20 | AC | 26 ms
24,028 KB |
testcase_21 | AC | 27 ms
25,884 KB |
testcase_22 | AC | 81 ms
42,848 KB |
testcase_23 | AC | 162 ms
54,572 KB |
testcase_24 | AC | 151 ms
52,404 KB |
testcase_25 | AC | 175 ms
54,220 KB |
testcase_26 | AC | 26 ms
23,912 KB |
testcase_27 | AC | 26 ms
25,812 KB |
testcase_28 | AC | 152 ms
54,368 KB |
testcase_29 | AC | 162 ms
54,496 KB |
testcase_30 | AC | 152 ms
54,240 KB |
testcase_31 | AC | 139 ms
52,056 KB |
testcase_32 | AC | 157 ms
54,448 KB |
コンパイルメッセージ
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.IO; using System.Security.Cryptography.X509Certificates; namespace Contest { class Scanner { public Scanner() { _stream = new StreamReader(Console.OpenStandardInput()); _pos = 0; _line = new string[0]; _separator = ' '; } private char _separator; private StreamReader _stream; private int _pos; private string[] _line; #region get a element public string Next() { if (_pos >= _line.Length) { _line = _stream.ReadLine().Split(_separator); _pos = 0; } return _line[_pos++]; } public int NextInt() { return int.Parse(Next()); } public long NextLong() { return long.Parse(Next()); } public double NextDouble() { return double.Parse(Next()); } #endregion #region convert array private int[] ToIntArray(string[] array) { var result = new int[array.Length]; for (int i = 0; i < array.Length; i++) { result[i] = int.Parse(array[i]); } return result; } private long[] ToLongArray(string[] array) { var result = new long[array.Length]; for (int i = 0; i < array.Length; i++) { result[i] = long.Parse(array[i]); } return result; } private double[] ToDoubleArray(string[] array) { var result = new double[array.Length]; for (int i = 0; i < array.Length; i++) { result[i] = double.Parse(array[i]); } return result; } #endregion #region get row elements #region get array public string[] Array() { if (_pos >= _line.Length) _line = _stream.ReadLine().Split(_separator); _pos = _line.Length; return _line; } public int[] IntArray() { return ToIntArray(Array()); } public long[] LongArray() { return ToLongArray(Array()); } public double[] DoubleArray() { return ToDoubleArray(Array()); } #endregion #region get 2~4 elements public void GetRow(out string a, out string b) { a = Next(); b = Next(); } public void GetRow(out string a, out string b, out string c) { a = Next(); b = Next(); c = Next(); } public void GetRow(out string a, out string b, out string c, out string d) { a = Next(); b = Next(); c = Next(); d = Next(); } public void GetIntRow(out int a, out int b) { a = NextInt(); b = NextInt(); } public void GetIntRow(out int a, out int b, out int c) { a = NextInt(); b = NextInt(); c = NextInt(); } public void GetIntRow(out int a, out int b, out int c, out int d) { a = NextInt(); b = NextInt(); c = NextInt(); d = NextInt(); } public void GetLongRow(out long a, out long b) { a = NextLong(); b = NextLong(); } public void GetLongRow(out long a, out long b, out long c) { a = NextLong(); b = NextLong(); c = NextLong(); } public void GetLongRow(out long a, out long b, out long c, out long d) { a = NextLong(); b = NextLong(); c = NextLong(); d = NextLong(); } public void GetDoubleRow(out double a, out double b) { a = NextDouble(); b = NextDouble(); } public void GetDoubleRow(out double a, out double b, out double c) { a = NextDouble(); b = NextDouble(); c = NextDouble(); } public void GetDoubleRow(out double a, out double b, out double c, out double d) { a = NextDouble(); b = NextDouble(); c = NextDouble(); d = NextDouble(); } #endregion #endregion #region get 2~4 column elements public void GetColumn(int n, out string[] a) { a = new string[n]; for (int i = 0; i < n; i++) { a[i] = Next(); } } public void GetColumn(int n, out string[] a, out string[] b) { a = new string[n]; b = new string[n]; for (int i = 0; i < n; i++) { GetRow(out a[i], out b[i]); } } public void GetColumn(int n, out string[] a, out string[] b, out string[] c) { a = new string[n]; b = new string[n]; c = new string[n]; for (int i = 0; i < n; i++) { GetRow(out a[i], out b[i], out c[i]); } } public void GetColumn(int n, out string[] a, out string[] b, out string[] c, out string[] d) { a = new string[n]; b = new string[n]; c = new string[n]; d = new string[n]; for (int i = 0; i < n; i++) { GetRow(out a[i], out b[i], out c[i], out d[i]); } } public void GetIntColumn(int n, out int[] a) { string[] sa; GetColumn(n, out sa); a = ToIntArray(sa); } public void GetIntColumn(int n, out int[] a, out int[] b) { string[] sa, sb; GetColumn(n, out sa, out sb); a = ToIntArray(sa); b = ToIntArray(sb); } public void GetIntColumn(int n, out int[] a, out int[] b, out int[] c) { string[] sa, sb, sc; GetColumn(n, out sa, out sb, out sc); a = ToIntArray(sa); b = ToIntArray(sb); c = ToIntArray(sc); } public void GetIntColumn(int n, out int[] a, out int[] b, out int[] c, out int[] d) { string[] sa, sb, sc, sd; GetColumn(n, out sa, out sb, out sc, out sd); a = ToIntArray(sa); b = ToIntArray(sb); c = ToIntArray(sc); d = ToIntArray(sd); } public void GetLongColumn(int n, out long[] a) { string[] sa; GetColumn(n, out sa); a = ToLongArray(sa); } public void GetLongColumn(int n, out long[] a, out long[] b) { string[] sa, sb; GetColumn(n, out sa, out sb); a = ToLongArray(sa); b = ToLongArray(sb); } public void GetLongColumn(int n, out long[] a, out long[] b, out long[] c) { string[] sa, sb, sc; GetColumn(n, out sa, out sb, out sc); a = ToLongArray(sa); b = ToLongArray(sb); c = ToLongArray(sc); } public void GetLongColumn(int n, out long[] a, out long[] b, out long[] c, out long[] d) { string[] sa, sb, sc, sd; GetColumn(n, out sa, out sb, out sc, out sd); a = ToLongArray(sa); b = ToLongArray(sb); c = ToLongArray(sc); d = ToLongArray(sd); } public void GetDoubleColumn(int n, out double[] a) { string[] sa; GetColumn(n, out sa); a = ToDoubleArray(sa); } public void GetDoubleColumn(int n, out double[] a, out double[] b) { string[] sa, sb; GetColumn(n, out sa, out sb); a = ToDoubleArray(sa); b = ToDoubleArray(sb); } public void GetDoubleColumn(int n, out double[] a, out double[] b, out double[] c) { string[] sa, sb, sc; GetColumn(n, out sa, out sb, out sc); a = ToDoubleArray(sa); b = ToDoubleArray(sb); c = ToDoubleArray(sc); } public void GetDoubleColumn(int n, out double[] a, out double[] b, out double[] c, out double[] d) { string[] sa, sb, sc, sd; GetColumn(n, out sa, out sb, out sc, out sd); a = ToDoubleArray(sa); b = ToDoubleArray(sb); c = ToDoubleArray(sc); d = ToDoubleArray(sd); } #endregion #region get matrix public string[][] GetMatrix(int h) { string[][] result = new string[h][]; for (int i = 0; i < h; i++) { result[i] = Array(); } return result; } public int[][] GetIntMatrix(int h) { int[][] result = new int[h][]; for (int i = 0; i < h; i++) { result[i] = IntArray(); } return result; } public long[][] GetLongMatrix(int h) { long[][] result = new long[h][]; for (int i = 0; i < h; i++) { result[i] = LongArray(); } return result; } public double[][] GetDoubleMatrix(int h) { double[][] result = new double[h][]; for (int i = 0; i < h; i++) { result[i] = DoubleArray(); } return result; } public char[][] GetCharMatrix(int h) { char[][] result = new char[h][]; for (int i = 0; i < h; i++) { result[i] = Next().ToCharArray(); } return result; } #endregion } class Program { public void Solve() { var sc = new Scanner(); int N = sc.NextInt(); int D = sc.NextInt(); var map = new int[10000001]; for (int w = 1; w <= N; w++) { int ww = w * w; for (int z = 1; z <= N; z++) { int right = ww - z * z + 5000000; map[right]++; } } long ans = 0; for (int x = 1; x <= N; x++) { int xx = x * x; for (int y = 1; y <= N; y++) { int left = xx + y * y - D + 5000000; if (left < map.Length) ans += map[left]; } } Console.WriteLine(ans); } static void Main(string[] args) => new Program().Solve(); } }