Created
January 14, 2016 14:36
-
-
Save kuuso/2aed68cc024b9aec33c0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections; | |
using System.Collections.Generic; | |
class TEST{ | |
static void Main(){ | |
Sol mySol =new Sol(); | |
mySol.Solve(); | |
} | |
} | |
class Sol{ | |
public void Solve(){ | |
// (x+y)(x-y)=(B-A)(B+A)=Z として、Zの約数から(x、y)が解けるものを選ぶ | |
long Z=(B-A)*(B+A); | |
long ans=0; | |
for(long i=1;i*i<=Z;i++){ | |
if(Z%i!=0)continue; | |
if(i*i==Z)continue;// case: (X+Y)==(X-Y) => Y==0 is not Natural Number; | |
if((i+Z/i)%2==0)ans+=Z/i; | |
} | |
Console.WriteLine(ans); | |
} | |
long A,B; | |
public Sol(){ | |
var d=rla(); | |
A=d[0];B=d[1]; | |
} | |
static long[] rla(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>long.Parse(e));} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment