氢气球
时间限制:
1000 ms | 内存限制:
65535 KB
难度:
3
-
描述
-
Ten mathematicians are flying on a balloon over the Pacific ocean. When they are crossing the equator they decide to celebrate this event and open a bottle of champagne. Unfortunately, the cork makes a hole in the balloon. Hydrogen is leaking out and the balloon is descending now. Soon it will fall into the ocean and all the balloonists will be eaten by hungry sharks.
But not everything is lost yet. One of the balloonists can sacrifice himself jumping out, so that his friends would live a little longer. Only one problem still exists ¾ who is the one to get out. There is a fair way to solve this problem. First, each of them writes an integer ai not less than 1 and not more than 10000. Then they calculate the magic number N that is the number of positive integer divisors of the product a1*a2*...*a10. For example, the number of positive integer divisors of 6 is 4 (they are 1,2,3,6). The hero (a mathematician who will be thrown out) is determined according to the last digit of N. Your task is to find this digit.-
输入
- The first line of input contains a number c(0<c<=1000) giving the number of cases that follow. each case contains ten numbers separated by a space. 输出
- Output each case of a single digit from 0 to 9 - the last digit of N 样例输入
-
1 1 2 6 1 3 1 1 1 1 1
样例输出
-
9
-
题目大意:每组给十个数就这是个数的积的因子个数取模十(每个数小于10000)。
-
//一个数所有质因子任意积的组合构成了它所有的因子 假如一个数有质因子a m个 b n个,则a可以选0,1,2...m个 b可选0,1,2...n个所有组合有(m+1)*(n+1)种, 由此此题可解 #include <stdio.h> #include <string.h> int num[10001]; int main() { int t, i, j, tmax, temp, ans; scanf("%d", &t); while(t--) { tmax = 0; memset(num, 0, sizeof(num)); for(i = 0; i < 10; i++) { scanf("%d", &temp); if(temp > tmax) { tmax = temp; } for(j = 2; temp != 1; j++) { while(temp % j == 0) { num[j]++; //统计质因子个数 temp /= j; } } } for(ans = 1, i = 2; i <= tmax; i++) { ans = ans * (num[i]+1) % 10; //将所有质因子个数加1相乘得解 } printf("%d\n", ans); } return 0; }