Question A is hard to understand. The number of quality factors that output the product of 10 numbers not greater than 100000
A large number is not allowed. The time is 2 S. X. First, we will learn the knowledge of a number theory:
Positive number N can be decomposed into P1 ^ A1 * P2 * A2 *...... * PK ^ AK
Pi is a pair of different prime numbers, and AI is the corresponding exponent. Because of N factors, you can select 0 and 1 ..... N is selected in n + 1. Then the approximate number of N is (1 + A1) * (1 + A2 )*.....
#include<iostream>#include<cmath>#include<algorithm>using namespace std;int a[10001];int main(){int i,j,n,re;for(i=1;i<=10;i++){scanf("%d",&n);for(j=2;;j++){while(n%j==0&&n!=1){a[j]++;n/=j;}if(n==1)break;}}re=1;for(i=2;i<=10000;i++){if(a[i]!=0){re=re*(a[i]+1);}}printf("%d\n",re%10);return 0;}
E:
The practice is heap. I would like to give up. Thanks to mango's reminder, I remember that there is such a good thing as priority_queue in STL, which has grown C ++'s power. Note that you only need to maintain half the length, otherwise the memory will still be stuck.
#include<iostream>#include<string>#include<cstdio>#include<queue>using namespace std;priority_queue<int>a;int main(){int N;double f;int x,mid,mid1,mid2,TT;int i;while(~scanf("%d",&N)){while(!a.empty ())a.pop();for(i=0;i<N;i++){scanf("%d",&x);a.push(x);//TT=a.top();//int len=a.size();if(a.size ()>N/2+1) a.pop();}if(N%2==0) {mid1=a.top();a.pop();mid2=a.top();a.pop();f=((double)mid1+(double)mid2)/2;printf("%.1lf\n",f);}else {mid=a.top();printf("%d.0\n",mid);}}return 0;}
Cherish the opportunity of each competition. Come on, I am really ashamed to see other acmers working so hard.