Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- ifstream f("exp.in");
- ofstream g("exp.out");
- bool ciur[30001];
- short h=0, nrp[3500],pw[3500];
- void eratostene()
- {
- int i, j;
- ciur[0]=ciur[1]=1;
- for (i=2; i<=173; ++i)
- {
- if(!ciur[i])
- {
- for (j=i*i; j<=30001; j+=i)
- ciur[j]=1;
- }
- }
- for(i=1; i<=30000; ++i)
- if(!ciur[i])
- nrp[++h]=i;
- }
- void factp(int a)
- {
- int f, p, k=0;
- f=nrp[++k];
- while (a>1)
- {
- p=0;
- while (a%f==0)
- a/=f, ++p;
- pw[k]+=p;
- f=nrp[++k];
- }
- }
- int main()
- {
- eratostene();
- cout<<nrp[h];
- short ord, n; int x;
- f>>ord>>n;
- short i;
- for (i=1; i<=n; ++i)
- {
- f>>x;
- factp(x);
- }
- for (i=1; i<=h; ++i)
- {
- if(pw[i]%ord)
- {
- g<<0;
- return 0;
- }
- else
- pw[i]/=ord;
- }
- g<<1<<'\n';
- for (i=1; i<=h; ++i)
- if(pw[i])
- g<<nrp[i]<<" "<<pw[i]<<'\n';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement