早教吧 育儿知识 作业答案 考试题库 百科 知识分享

ACM比赛运算超时DescriptionLonglongago,thereisagreatking.Todefendhiscountry,hebuiltmanycastlesnumberedfrom1toN.Inthei-thcastlewhichisco-primewithN,heapportionageneral,ifhostilecountrywanttokillthegeneral,hew

题目详情
ACM 比赛 运算超时
Description
Long long ago,there is a great king.To defend his country,he built many castles numbered from 1 to N.In the i-th castle which is co-prime with N,he apportion a general,if hostile country want to kill the general,he will lose one unit.He wants you to help him count number of unit he need.
Two numbers are co-prime if their great common divisor is 1.
Input
The first line contains a single integer T (2
▼优质解答
答案和解析
#include
#include
int p[100001], phi[100001];
int main() {
memset(p,0,sizeof(p));
for (int i=2;i