Easy Number Challenge
Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u
Submit Status Practice CodeForces 236B
Appoint description:
System Crawler (2016-04-26)
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
Input
2 2 2
Output
20
Input
5 6 7
Output
1520
Hint
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的因子的个数;还好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; }
时间: 2024-10-10 16:10:02