Advertisement
Guest User

Untitled

a guest
Jun 4th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. #include<set>
  2. #include<utility>
  3. #include<deque>
  4. #include<math.h>
  5. using namespace std;
  6. template<class T1,class T2> bool pair<T1,T2>operator< (const pair<T1,T2> &other)
  7. {
  8. if(first==other.first)return second<other.second;
  9. return first<other.first;
  10. }
  11. int P, M;
  12. void inizializza(int P, int M) {
  13.  
  14. ::P = P;
  15. ::M = M;
  16. }
  17. set <pair<int , int>> S;
  18. set<int>::iterator valore_rtovato;
  19. pair <int, int > tro;
  20. int controlla(int checksum)
  21. {
  22. int radice=sqrt(checksum);
  23. deque < pair<int,int>>tmp;
  24. for(int i=2;i<radice;i++)
  25. {
  26. if(checksum%i==0)
  27. tmp.push_back(make_pair(i, checksum));
  28. }
  29. if(tmp.size()==0)
  30. tmp.push_back(make_pair(checksum, checksum));
  31. int valore;
  32. for(int i=0; i<tmp.size();i++)
  33. {
  34. if(S.count(tmp[i].first)==0)
  35. S.insert(tmp[i]);
  36. else
  37. {
  38. valore_trovato=S.find(tmp[i].first);
  39. tro=*valore_trovato;
  40. return tro.second;
  41. }
  42. }
  43. return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement