日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

数学--数论--HDU 2582 F(N) 暴力打表找规律

發布時間:2023/12/15 编程问答 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 数学--数论--HDU 2582 F(N) 暴力打表找规律 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

This time I need you to calculate the f(n) . (3<=n<=1000000)

f(n)= Gcd(3)+Gcd(4)+…+Gcd(i)+…+Gcd(n).
Gcd(n)=gcd(C[n][1],C[n][2],……,C[n][n-1])
C[n][k] means the number of way to choose k things from n some things.
gcd(a,b) means the greatest common divisor of a and b.
Input
There are several test case. For each test case:One integer n(3<=n<=1000000). The end of the in put file is EOF.
Output
For each test case:
The output consists of one line with one integer f(n).
Sample Input
3
26983
Sample Output
3
37556486
題目就是這么短小精悍,這題我實在不知道怎么寫,然后也不會數論的推理,我就打了表,發現跟質數的關系很大,就順著推了一下, 就過了。

#include <iostream> #include<cstdio> #define ll long long #define maxn 1000000 using namespace std; int zs[maxn], t = 0, n; ll f[maxn + 5]; bool v[maxn + 5];int main() {for (int i = 2; i <= maxn; i++){if (!v[i]) f[i] = zs[++t] = i;for (int j = 1,u = zs[j] * i; j <= t && u<= maxn; j++){v[u] = 1;if (!(i % zs[j])){f[u] = f[i];break;}f[u] = 1;u = zs[j+1] * i; }}for (int i = 4; i <= maxn; i++)f[i] += f[i - 1];while (scanf("%d", &n)!=EOF)printf("%lld\n", f[n]);return 0; }

總結

以上是生活随笔為你收集整理的数学--数论--HDU 2582 F(N) 暴力打表找规律的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。