HDU-2601-An easy problem

题目链接

http://acm.hdu.edu.cn/showproblem.php?pid=2601

这题如果直接暴力的话,就会超时,我们需要变化
n=i*j + i + j  ;n=i*(j+1) + j; n+1=(i+1)*(j+1);
就取余,就只要 一层循环了

我的代码

#include<stdio.h>
#include<math.h>
#include<string.h>
int main(void)
{
__int64 t,i,j,s,n;
scanf("%I64d",&t);
while(t--)
{
scanf("%I64d",&n);
n++; s=0;
int k=sqrt(n);
for(i=2;i<=k;i++)
{
if(n%i==0)
s++;
}
printf("%I64d ",s);
}
return 0;
}

原文地址:https://www.cnblogs.com/liudehao/p/3959775.html