Posted on 2010-09-10 14:42
acronix 阅读(332)
评论(0) 编辑 收藏 引用 所属分类:
hzshuai解题中算法总结
/* a / b (mod n) = a % (b * n) / b (mod n)*\
|| 有除法的取模!! */
#include <cstdio>
const int mod = 10000;
int main()
{
long long n;
while (scanf("%I64d",&n) != EOF)
{
n = n*(n+1);
n = (n % (2*mod) / 2) % mod;
n = n*n % mod;
printf("%04I64d\n",n);
}
return 0;
}