京东第二题 暴力破解
static boolean isPrime(long n){
long s=(long) Math.sqrt(n);
for(long i=2;i<=s;i++){
if(n%i==0)
return false;
}
return true;
}
//long mod=1000000007;
static long numParameter(long b){
long s=(long) Math.sqrt(b);
long count=0;
for(long i=2;i<=s;i++){
if(b%i==0){
count=(count+2)%mod;
}
}
return count%mod;
}
public static void main(String[] args) {
Scanner in=new Scanner(System.in);
while(in.hasNext()){//注意while处理多个case
long n=in.nextLong();
if(n<1)
System.out.println(0);
else{
long sum=0;
for(long i=1;i<=n;i++){
for(long j=1;j<=n;j++){
long a=i;
long b=j;
long s=(long)Math.pow(a,b);
if(s==1){
sum=(sum+n*n)%mod;
break;
}else{
//panduan is sushu
if(isPrime(a)&&isPrime(b)){//it is prime
sum=(sum+1)%mod;
//System.out.println(j+" "+sum);
}else{
if(isPrime(a)&&!isPrime(b)){
//qiu yinzi sum
long num=numParameter(b);
sum=(sum+num+1)%mod;
}else if(!isPrime(a)&&isPrime(b)){
//qiu yinzi sum
long num=numParameter(a);
sum=(sum+num+1)%mod;
}else{
//qiu yinzi sum
long num1=numParameter(b);
long num2=numParameter(a);
long num=(num1*num2)%mod;
sum=(sum+num+1)%mod;
}
}
}
}
}
sum=sum%mod;
System.out.println(sum);
}
}