标签:
Description
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).
Sample Input
2 2 2
20
5 6 7
1520
Hint
For the first example.
So the result is 1 + 2 + 2 + 3 + 2 + 3 + 3 + 4 = 20.
题解:
d(x)代表x的因子的个数;还好i,j,k都不大,100,暴力就行,直接由于因子个数等于质因子的系数加一之积,反素数讲过,由此可得;
代码:
#include<stdio.h> #include<string.h> #include<math.h> #include<algorithm> #include<iostream> #include<set> #define ll long long #define MOD 1073741824 using namespace std; int num[110]; int main() { int a,b,c; int i,j,k; while(scanf("%d%d%d",&a,&b,&c)!=EOF) { memset(num, 0, sizeof(num)); ll sum=0, temp; set<int>st; set<int>::iterator iter; for(i=1;i<=a;i++) { for(j=1;j<=b;j++) { for(k=1;k<=c;k++) { temp = i * j * k; ll cnt = 1; for(int p = 2; p <= temp; p++){ if(temp % p == 0){ int cur = 0; while(temp % p == 0){ temp /= p; cur++; } cnt *= cur + 1; } } sum += cnt; sum %= MOD; } } } printf("%lld\n",sum); } return 0; }
Easy Number Challenge(暴力,求因子个数)
标签:
原文地址:http://www.cnblogs.com/handsomecui/p/5440207.html