欧拉函数
overload1997
努力 努力 再努力
展开
-
poj2478 Farey Sequence
//pku2478 //思路,dp,递推方式为dp[i] =dp[i-1]+phi[i]; #include #include #include #include using namespace std; typedef long long LL; const int maxn=1e6+5; int phi[maxn+10]; LL dp[maxn+10]; int main() { i原创 2016-09-07 16:40:48 · 210 阅读 · 0 评论 -
poj3696 The Luckiest number
The Luckiest numberTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 5120 Accepted: 1370DescriptionChinese people think of '8' as the lucky digit. Bob also likes digit '8'. Moreover, Bob has h原创 2016-09-07 16:42:29 · 248 阅读 · 0 评论 -
O(n)欧拉函数+素数筛选
用最小的素因子筛掉每个数 int prime[N],phi[N],cnt;// prime:记录质数,phi记录欧拉函数 int Min_factor[N];// i的最小素因子 bool vis[N]; void Init() { cnt=0; phi[1]=1; int x; for(int i=2;i<N;i++)转载 2016-10-01 17:42:32 · 336 阅读 · 0 评论