using System;
using System.Collections.Generic;
class Program
{
static void Main()
{
int AnswerCnt = 0;
for (int LoopSyokou = 1; LoopSyokou <= 148; LoopSyokou++) {
List<BunsuuDef> RList = Solve2JiHouteishiki(LoopSyokou, LoopSyokou, LoopSyokou - 111);
foreach (BunsuuDef EachR in RList) {
int Kou2Bunsi = LoopSyokou * EachR.Bunsi;
//分母を払えなかったら、整数でない
if (Kou2Bunsi % EachR.Bunbo != 0) continue;
int Kou2 = Kou2Bunsi / EachR.Bunbo;
int Kou3Bunsi = Kou2 * EachR.Bunsi;
//分母を払えなかったら、整数でない
if (Kou3Bunsi % EachR.Bunbo != 0) continue;
int Kou3 = Kou3Bunsi / EachR.Bunbo;
AnswerCnt++;
Console.WriteLine("解{0,2}を発見。等比数列は{1,3},{2,4},{3,3}",
AnswerCnt, LoopSyokou, Kou2, Kou3);
}
}
}
struct BunsuuDef
{
internal int Bunsi;
internal int Bunbo;
}
//2次方程式の解を返す
static List<BunsuuDef> Solve2JiHouteishiki(int pA, int pB, int pC)
{
var WillReturn = new List<BunsuuDef>();
int IntHanbetuShiki = pB * pB - 4 * pA * pC;
//平方数でない場合
double DoubleHanbetuShiki = (double)IntHanbetuShiki;
int wkSqrt = (int)(Math.Truncate(Math.Sqrt(DoubleHanbetuShiki)));
if (wkSqrt * wkSqrt != IntHanbetuShiki) return WillReturn;
WillReturn.Add(new BunsuuDef() { Bunsi = -pB + wkSqrt, Bunbo = 2 * pA });
WillReturn.Add(new BunsuuDef() { Bunsi = -pB - wkSqrt, Bunbo = 2 * pA });
//重解の場合
if (IntHanbetuShiki == 0) WillReturn.RemoveAt(1);
return WillReturn;
}
}
解 1を発見。等比数列は 1, 10,100
解 2を発見。等比数列は 1, -11,121
解 3を発見。等比数列は 27, 36, 48
解 4を発見。等比数列は 27, -63,147
解 5を発見。等比数列は 37, 37, 37
解 6を発見。等比数列は 37, -74,148
解 7を発見。等比数列は 48, 36, 27
解 8を発見。等比数列は 48, -84,147
解 9を発見。等比数列は100, 10, 1
解10を発見。等比数列は100,-110,121
解11を発見。等比数列は111, 0, 0
解12を発見。等比数列は111,-111,111
解13を発見。等比数列は121, -11, 1
解14を発見。等比数列は121,-110,100
解15を発見。等比数列は147, -63, 27
解16を発見。等比数列は147, -84, 48
解17を発見。等比数列は148, -74, 37