HDU 5528 Count a * b(数论) 2022-01-04 HDOJ k(n)=n*n-f(n) 可以知道对于一个k(p1^a1*p2^a2....pn^a2)=k(k1^a1)*....*k(kn^an) 然后又对于k(p^a)=(a+1)*(p^a)-k*(p^a-1) 那么对于g(n)=约数平方和+素数的h的和的乘机 #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define sp system("pause")typedef long long ll; typedef unsigned long longull; typedef pair pii; typedef pair piii; const int MAXN = 32000 + 500; int prime[MAXN + 1]; vectormyp; void getprime() { memset(prime, 0, sizeof prime); for (int i = 2; i <= MAXN; i++) { if (!prime[i])prime[++prime[0]] = i, myp.push_back(i); for (int j = 1; j <= prime[0] && prime[j] <= MAXN / i; j++) { prime[prime[j] * i] = 1; if (i%prime[j] == 0)break; } } }vector【HDU 5528 Count a * b(数论)】fac; void getfac(int x) { for (int i = 0; i < myp.size(); i++) { int cot = 0; while (x%myp[i] == 0)x /= myp[i], cot++; if (cot)fac.push_back(pii(myp[i], cot)); } if (x>1)fac.push_back(pii(x, 1)); }int main() { int T; getprime(); cin >> T; while (T--) { int x; scanf("%d", &x); ull tx = x; fac.clear(); getfac(x); ull all = 0; //for (ull i = 1; i*i <= tx; i++) // if(tx%i==0)all += i*i,all+=(tx/i)*(tx/i); ull now = 1; for (int i = 0; i < fac.size(); i++) { ull diall = 1; ull nowplus = fac[i].first; ull nowpow = 0; ull cotall = 0; for (int j = 1; j <= fac[i].second; j++) { diall += (ull)(j + 1)*(nowplus)-((ull)j*nowplus / fac[i].first); nowpow = nowpow + nowplus*nowplus; nowplus =nowplus*(ull) fac[i].first; } all = all*(nowpow + 1); all = all + nowpow; now *= diall; } all++; printf("%llu\n", all - now); } }//int main() //{ // int cot[200] = { 0 }; // for (int i = 1; i <= 40; i++) // { //for (int j = 1; j <= i; j++) //{ //for (int k = 1; k <= i; k++) //{ //if ((k*j) % i == 0)cot[i]++; //} //} // } // for (int i = 1; i <= 40; i++) //cout << i << " " << cot[i] << endl; // sp; //} 推荐阅读 社保卡发放城乡居民基本养老保险待遇 肇庆2月份起全面使用 山东麦收是几月份,麦收后种植什么经济作物 建筑工程技术主要考哪些证好考吗 海尔洗衣机不能洗涤是什么原因,主要差别在这里 手机|华为手机越做越大,越来越重;苹果则越来越小,越来越轻薄 PS制作另类高光黑白照片 掩于岁月敬而远之是什么意思 陈皮加枸杞泡水喝有什么作用 丝绸之路的意义是什么 关于丝绸之路的意义介绍 教师招聘体检哪些不合格不能通过 医生|又有患者不讲武德!医生“飞刀”手术后被举报:退还手术费还得道歉 如何把视频的声音提取成文字?视频转文字方法分享 做肝血管瘤介入有啥副作用,肝血管瘤介入手术有何并发症 如何刷机安卓手机,如何进行强制刷机? Win10电脑的微软商店不见了怎么办?教你重新安装Microsoft Store详细方法 范忆琳个人资料 运动员范忆琳个人简介 爱玩mc官网 爱玩mc如何直播,爱玩mc联机装mod Win7旗舰版打开文件提示安全警告怎么取消? mongodb文件格式 mongodb写入文件 银耳泡后软粘是怎么回事 HDOJ-1003-Max Sum