问题描述:

HD-ACM算法专攻系列(20)——七夕节

HD-ACM算法专攻系列(20)——七夕节

 

 

AC源码:

 

/**/
#include"iostream"
#include"cmath"

using namespace std;

int main()
{
	int t, n, sq, sum;
	scanf("%d", &t);
	for(int i = 0; i < t; i++)
	{
		scanf("%d", &n);
		sum = 1;
		sq = (int)sqrt(n);
		for(int j = 2; j <= sq; j++)
		{
			if(n % j == 0)
			{
				sum += j + n / j;
			}
		}
		if(sq > 1 && sq*sq == n)
		{
			sum -= sq;
		}
		printf("%d\n", sum);
	}
    return 0;
}

  

相关文章:

  • 2021-07-01
  • 2021-12-25
  • 2021-06-12
  • 2021-09-10
  • 2021-10-25
  • 2021-06-17
  • 2021-12-28
  • 2021-07-03
猜你喜欢
  • 2021-11-14
  • 2021-11-15
  • 2021-12-30
  • 2022-01-17
  • 2021-06-20
  • 2022-01-27
  • 2021-10-29
相关资源
相似解决方案