D. Fun with Integers

194 篇文章 1 订阅
44 篇文章 0 订阅
给定一个正整数 n,你需要找到所有可能的整数对 (a, b),使得存在绝对值大于1的整数 x 满足 a * x = b 或 b * x = a。每次转换会增加分数 |x|,且不能重复转换同一对整数。求能获得的最大分数。输入一个整数 n,输出最大可能得分。示例中展示了不同 n 的得分情况。" 41249981,1519681,Python实现多线程HTTP失败切换策略,"['Python编程', '并发处理', '网络请求', '错误处理']
摘要由CSDN通过智能技术生成

链接:https://codeforces.com/group/nhsfFrN6WT/contest/266629/problem/D

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

Copy

4

output

Copy

8

input

Copy

6

output

Copy

28

input

Copy

2

output

Copy

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.

代码:

#include<bits/stdc++.h>
using namespace std;
long long n,t,b,k,c,l,r,ans,vis=1,p,mx=0,kk=0,y=0;
long long a[1000001],x[1000001];
map<long long,long long>q[1000001];
long long s[1000001];
int main()
{
	cin>>n;
	ans=0;
	for(int i=2;i<=n;i++)
	{
		k=sqrt(i);
		l=0;
		s[i]=0;
		for(int j=2;j<=k;j++)
		{
			if(i%j==0)
			{
				if(q[i][j]==0)
				{
					l++;
					s[i]+=(i/j)*4;
					q[i][j]=1;
				}
				if(q[i][i/j]==0)
				{
					l++;
					s[i]+=j*4;
					q[i][i/j]=1;
				}
			}
		}
		ans+=s[i];
	}
	cout<<ans;
	return 0;
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值