Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <algorithm>
- #include <iostream>
- #include <sstream>
- #include <string>
- #include <vector>
- #include <list>
- #include <queue>
- #include <stack>
- #include <set>
- #include <map>
- #include <cstdio>
- #include <cstdlib>
- #include <cctype>
- #include <cmath>
- #include <cstring>
- #include <ctime>
- using namespace std;
- typedef unsigned long long LL;
- #define FOR(k,a,b) for(int k(a); k < (b); ++k)
- #define FORD(k,a,b) for(int k(a-1); k >= (b); --k)
- #define REP(k,a) for(int k=0; k < (a); ++k)
- #define REPD(k,a) for(int k=a-1; k >-1; --k)
- #define ABS(a) ((a)>0?(a):-(a))
- struct ITEM
- {
- LL val;
- LL counter;
- vector<int> expo;
- };
- // int calc(vector<int>& v,map<vector<int>,int>& m)
- // {
- //
- // }
- int main()
- {
- #ifdef HOME
- // freopen ("in.1","r",stdin);
- // freopen ("out.txt","w",stdout);
- #endif
- const int mMax=10002;
- const LL goal=1e10;
- vector<bool> sieve(mMax,true);
- list<ITEM> l;
- list<ITEM>::iterator lit,lend;
- map<vector<int>,int> m,mm;
- FOR(i,2,mMax)
- {
- if(sieve[i])
- {
- for(int j=2*i;j<mMax;j+=i)
- {
- sieve[j]=false;
- }
- }
- }
- FOR(i,2,mMax)
- {
- if(!sieve[i])
- continue;
- LL tmp=i;
- LL ctr=0;
- int expo=1;
- while(tmp*i<=goal)
- {
- tmp*=i;
- expo++;
- }
- LL maxtmp=tmp;
- LL maxexpo=expo;
- while(tmp>1)
- {
- LL subctr=goal/tmp-ctr;
- ctr+=subctr;
- ITEM item;
- item.val=tmp;
- item.counter=ctr;
- item.expo.push_back(expo);
- l.push_back(item);
- tmp/=i;
- --expo;
- }
- for(lit=l.begin();lit!=l.end();)
- {
- if(!(lit->val%i))
- break;
- ITEM& act=*lit;
- if(act.val*i>goal)
- {
- sort(act.expo.begin(),act.expo.end());
- ++m[act.expo];
- l.erase(lit++);
- continue;
- }
- tmp=maxtmp;
- expo=maxexpo;
- ctr=0;
- while(tmp>1)
- {
- if(tmp*act.val<=goal)
- {
- ITEM cand;
- cand.val=tmp*act.val;
- cand.counter=act.counter/tmp-ctr;
- //act.counter-=cand.counter;
- ctr+=cand.counter;
- cand.expo=act.expo;
- cand.expo.push_back(expo);
- if(cand.counter && cand.val*(i)<goal)
- {
- l.push_back(cand);
- }
- else
- {
- sort(cand.expo.begin(),cand.expo.end());
- ++m[cand.expo];
- }
- }
- tmp/=i;
- --expo;
- }
- ++lit;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment