Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<set>
- #include<utility>
- #include<deque>
- #include<math.h>
- using namespace std;
- template<class T1,class T2> bool pair<T1,T2>operator< (const pair<T1,T2> &other)
- {
- if(first==other.first)return second<other.second;
- return first<other.first;
- }
- int P, M;
- void inizializza(int P, int M) {
- ::P = P;
- ::M = M;
- }
- set <pair<int , int>> S;
- set<int>::iterator valore_rtovato;
- pair <int, int > tro;
- int controlla(int checksum)
- {
- int radice=sqrt(checksum);
- deque < pair<int,int>>tmp;
- for(int i=2;i<radice;i++)
- {
- if(checksum%i==0)
- tmp.push_back(make_pair(i, checksum));
- }
- if(tmp.size()==0)
- tmp.push_back(make_pair(checksum, checksum));
- int valore;
- for(int i=0; i<tmp.size();i++)
- {
- if(S.count(tmp[i].first)==0)
- S.insert(tmp[i]);
- else
- {
- valore_trovato=S.find(tmp[i].first);
- tro=*valore_trovato;
- return tro.second;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement