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

歡迎訪問 生活随笔!

生活随笔

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

编程问答

CodeForce 236B Easy Number Challenge(筛法求素数 + 整数因式分解)

發布時間:2025/3/16 编程问答 21 豆豆
生活随笔 收集整理的這篇文章主要介紹了 CodeForce 236B Easy Number Challenge(筛法求素数 + 整数因式分解) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
題目鏈接:http://codeforces.com/problemset/problem/236/B Easy Number Challenge time limit per test 2 seconds memory limit per test 256 megabytes

Let's denote?d(n)?as the number of divisors of a positive integer?n. You are given three integers?a,?b?and?c. Your task is to calculate the following sum:

Find the sum modulo?1073741824?(230).

Input

The first line contains three space-separated integers?a,?b?and?c?(1?≤?a,?b,?c?≤?100).

Output

Print a single integer — the required sum modulo?1073741824?(230).

Examples input 2 2 2 output 20 input 5 6 7 output 1520 Note

For the first example.

  • d(1·1·1)?=?d(1)?=?1;
  • d(1·1·2)?=?d(2)?=?2;
  • d(1·2·1)?=?d(2)?=?2;
  • d(1·2·2)?=?d(4)?=?3;
  • d(2·1·1)?=?d(2)?=?2;
  • d(2·1·2)?=?d(4)?=?3;
  • d(2·2·1)?=?d(4)?=?3;
  • d(2·2·2)?=?d(8)?=?4.

So the result is?1?+?2?+?2?+?3?+?2?+?3?+?3?+?4?=?20.


題意:首先定義d(x)表示x的因子個數。然后給出三個正整數a、b、c,求 #include <cstdio> #include <iostream> #include <cstring> #include <set> #include <cmath> using namespace std; typedef long long LL; const int Mod = 1073741824; int prime[1000000], vis[10000050];int pri_cnt; void get_prime() { // 篩法求素數int m = (int)sqrt(100000 + 1);pri_cnt = 0;memset(vis, 0, sizeof(vis));vis[0] = 1;vis[1] = 1;for(int i = 2; i <= m; ++i) {if(!vis[i]) {prime[pri_cnt++] = i;for(int j = i * i; j <= 1000005;j += i)vis[j] = 1;}} }int get_cnt(int x) { // 求x的因數有多少個if(x == 1) return 1;if(!vis[x]) return 2;int ans = 1;for(int i = 0; x != 1 && i < pri_cnt; ++i) {int cnt = 0;while(x % prime[i] == 0) {cnt++;x /= prime[i];}ans = ans * (cnt + 1);}return ans; }int main() {get_prime();int a, b, c;while(~scanf("%d%d%d", &a, &b, &c)) {int ans = 0;for(int i = 1; i <= a; ++i) {for(int j = 1; j <= b; ++j) {for(int k = 1; k <= c; ++k) {ans = (ans + get_cnt(i * j * k)) % Mod;}}}printf("%d\n", ans);}return 0; }

與50位技術專家面對面20年技術見證,附贈技術全景圖

總結

以上是生活随笔為你收集整理的CodeForce 236B Easy Number Challenge(筛法求素数 + 整数因式分解)的全部內容,希望文章能夠幫你解決所遇到的問題。

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