http://poj.org/problem?id=1284
参考《数论概论》定理21.2:
完整代码:
/*16ms,652KB*/
#include <cstdio>
const int mx = 65536;
int phi[mx];
void phi_table()
{
int i, j;
for (i = 2; i < mx; ++i)
if (!phi[i])
for (j = i; j < mx; j += i)
{
if (!phi[j]) phi[j] = j;
phi[j] -= phi[j] / i;
}
}
int main()
{
phi_table();
int p;
while(~scanf("%d",&p))
printf("%d\n",phi[p-1]);
return 0;
}

本文详细介绍了数论概论中的定理21.2,并提供了基于该定理的完整代码实现。通过POJ在线编程平台进行实践,展示了如何将理论知识应用于实际编程问题解决。
3万+

被折叠的 条评论
为什么被折叠?



