Light OJ 1007
生活随笔
收集整理的這篇文章主要介紹了
Light OJ 1007
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
求區(qū)間歐拉函數(shù)平方和。。。
最后因為longlong 范圍爆了WA 了, 0.0
#include<bits/stdc++.h> using namespace std; const int maxn = 5000000 + 131; typedef unsigned long long LL;bool Com[maxn]; LL Num[maxn], Prim[maxn / 3]; int Cnt;void INIT() {Num[1] = 1, Num[0] = 0;for(LL i = 2; i <= maxn; ++i){if(!Com[i]){Prim[Cnt++] = i;Num[i] = i-1;}for(LL j = 0; j < Cnt && i * Prim[j] < maxn; ++j){Com[i*Prim[j]] = true;if(i % Prim[j] == 0){Num[i*Prim[j]] = Num[i] * Prim[j];break;}elseNum[i*Prim[j]] = Num[i] * (Prim[j]-1);}}for(LL i = 0; i < maxn; ++i) Num[i] *= Num[i];for(LL i = 1; i < maxn; ++i) Num[i] += Num[i-1]; }int main() {INIT();//cout << Num[maxn - 1] << endl;int t, a, b;scanf("%d",&t);for(int kase = 1; kase <= t; ++ kase){scanf("%d%d",&a,&b);a = a - 1;printf("Case %d: %llu\n",kase, Num[b]-Num[a]);} }?
轉(zhuǎn)載于:https://www.cnblogs.com/aoxuets/p/4915120.html
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎勵來咯,堅持創(chuàng)作打卡瓜分現(xiàn)金大獎總結(jié)
以上是生活随笔為你收集整理的Light OJ 1007的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: PyPDF2.py 合并pdf时报错问题
- 下一篇: 购物中心潮--我的创业之路