您的位置:首页 > 理论基础 > 计算机网络

http://acm.hdu.edu.cn/showproblem.php?pid=1787 典型 欧拉函数(为何c++ 那样会RE)

2010-08-04 23:59 387 查看
]#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
const int  N = 10005;
bool hash
;
int main()
{
int n;
memset(hash, false, sizeof(hash));
for(int i = 2; i <= 100; i++)
if(!hash[i])
for(int j = i * i; j < N; j += i)
hash[j] = true;
while( scanf("%d", &n) != EOF && n)
{
int s = n;
int sum = n;
bool flag;
//for(int i = 2; i <= (int)sqrt(1.0 * n); i++) // 这样RE  ??
for(int i = 2; i < N; i++)
{
if(hash[i])
continue;
flag = false;
if(s == 1 || i > n)
break;
while(true)
{
if(s % i != 0 || s == 1)
break;
flag = true;
s /= i;
}
if(flag)
sum = sum / i * (i - 1);
}

if(s > 1)
sum = sum / s * (s - 1);
//printf("%d/n", sum);
printf("%d/n", n - sum - 1);
}
return 0;
}
 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  c++ include