1152 cell division

Source: Internet
Author: User

1152 cell division

2009 Noip National League popularity Group

time limit: 1 sspace limit: 128000 KBtitle level: Golden Gold SolvingTitle Description Description

Dr. Hanks is a leading expert in the field of BT (Bio-tech, Biotechnology). Now he is preparing for a cell experiment: culturing cell samples.
Dr. Hanks now has N species of cells, numbered from 1~n, and an I cell can be split into Si cells after 1 seconds (SI is a positive integer). Now he needs to pick one of the cells and put it in a petri dish and let it split up and grow. After a period of time, all the cells in the petri dish are evenly divided into m-Test tubes to form a M-sample for experimentation. Dr. Hanks's number of tubes is large, and the basic data type of a normal computer cannot store such a large m-value, but fortunately, M can always be represented as a m2 of M1, that is, M = m1^ m2, where m1,m2 are positive integers that the base data type can store.
Note that a single cell is not allowed to be split during the entire experiment, such as when there are 4 cells in a petri dish at some point, Dr. Hanks can divide them into 2 test tubes, 2 in each test tube, and then begin the experiment. But if there are 5 cells in the Petri dish, the doctor will not be able to divide them into 2 test tubes. At this point, the doctor can only wait for a period of time, so that cells continue to divide, so that the number can be divided evenly, or simply change another cell culture.
In order for the experiment to begin as early as possible, Dr. Hanks stopped cell culture and began experimenting when a cell was selected to be cultured, and the resulting cells were "just as evenly divided into m-tubes". Now the doctor wants to know which cell culture to choose, which can make the start time of the experiment earliest.

Enter a description Input Description

There are three lines.
The first line has a positive integer N, which represents the number of cells.
The second line has two positive integer m1,m2, separated by a space, m1^ m2 that represents the total number of m in the test tube.
The third row has N positive integers, and the number of I SI indicates the number of cells that can be split into the same cells after 1 seconds.

Output description Output Description

A total of one row, which is an integer that represents the minimum time (in seconds) from the start of culturing the cell to the beginning of the experiment.
If Dr Hanks chooses which cell does not satisfy the requirement, the output integer-1.

Sample input Sample Input

1
2 1
3

Sample output Sample Output

-1

Data range and Tips Data Size & Hint

After 1 seconds, the cells split into 3, after 2 seconds, the cells split into 9, ..., and you can see that no matter how divided, the number of cells is odd, and therefore can never be divided into 2 test tubes.

Category labels Tags Click here to expandNOIP National League popular Group mainland region 2009 years The following:The unique decomposition theorem
#include <cstdio>using namespacestd;#defineN 30001#definell Long Longll S[n];intHash[n];intn,m,t,js,maxz,maxn,minn=0x7fffffff;intMain () {scanf ("%d%d%d",&n,&m,&t);  for(intI=0; i<n;i++) scanf ("%lld",&S[i]); if(m==1) {printf ("0\n");return 0;} intJ,i=2;  while(m!=1){         while(m%i==0) {m/=i; Hash[i]++; }        if(i>maxz) Maxz=i; Hash[i++]*=T; }    intans=0;  for(i=0; i<n;i++) {MAXN=0;  for(j=2; j<=maxz;j++){            if(hash[j]==0)                Continue; JS=0;  while(s[i]%j==0) {S[i]/=J; JS++; }            if(!JS) {MAXN=0x7fffffff;  Break; }            if((hash[j]-1)/JS&GT;MAXN) maxn= (hash[j]-1)/JS; }        if(maxn<Minn) {Minn=MAXN; Ans=MAXN; }     }    if(ans==0) printf ("-1\n"); Elseprintf ("%d\n", ans+1); return 0;}

1152 cell division

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.