Fun with Integers
You are given a positive integer nn greater or equal to 22 . For every pair of integers aa and bb (2≤|a|,|b|≤n2≤|a|,|b|≤n ), you can transform aa into bb if and only if there exists an integer xx such that 1<|x|1<|x| and (a⋅x=ba⋅x=b or b⋅x=ab⋅x=a ), where |x||x| denotes the absolute value of xx .
After such a transformation, your score increases by |x||x| points and you are not allowed to transform aa into bb nor bb into aa anymore.
Initially, you have a score of 00 . You can start at any integer and transform it as many times as you like. What is the maximum score you can achieve?
Input
A single line contains a single integer nn (2≤n≤1000002≤n≤100000 ) — the given integer described above.
Output
Print an only integer — the maximum score that can be achieved with the transformations. If it is not possible to perform even a single transformation for all possible starting integers, print 00 .
Examples
Input
4
Output
8
Input
6
Output
28
Input
2
Output
0
Note
In the first example, the transformations are 2→4→(−2)→(−4)→22→4→(−2)→(−4)→2 .
In the third example, it is impossible to perform even a single transformation.
題意很簡單,就是在區間2到n之間,找尋有多少對a*x=b或者b*x=a的x的絕對值總和,看程式碼你可能更容易理解,雖然我做的時候一直不敢暴力,導致被卡了很久,但是暴力還是很棒的。記住都是絕對值的,並且a和b的情況要數清楚。
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<string>
#include<map>
#include<math.h>
#define inf 0x3f3f3f3f
using namespace std;
int main()
{
long long int n;
while(~scanf("%lld",&n))
{
if(n==2)
printf("0\n");
else
{
long long num=0;
for(long long i=2; i<=n; i++)
{
for(long long j=2;; j++)
{
if(i*j>n)
break;
num+=j*4;
}
}
printf("%lld\n",num);
}
}
return 0;
}