Advertisement
Brick99

WCI PEG Super Special Awesome Numbers

May 26th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.85 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <utility>
  4. #include <algorithm>
  5. #include <cmath>
  6. using namespace std;
  7.  
  8. bool awesome(int broj)
  9. {
  10.     for (int i=2;i<=sqrt(broj);i++)
  11.         if (broj % (i*i) == 0) return false;
  12.     return true;
  13. }
  14.  
  15. bool special(int broj)
  16. {
  17.     int brojn=broj%10;
  18.     broj/=10;
  19.  
  20.     int brojnep=0;
  21.  
  22.     if (brojn%2!=0) brojnep++;
  23.  
  24.     while (broj!=0)
  25.     {
  26.         int e=broj%10;
  27.         if (e%2!=0) brojnep++;
  28.         if (brojn<=e) {return false;}
  29.         brojn=e;
  30.         broj/=10;
  31.     }
  32.  
  33.     if (brojnep%2!=0) return false;
  34.  
  35.     return prov;
  36. }
  37.  
  38. int main()
  39. {
  40.     int tests=5;
  41.  
  42.     int l,u;
  43.  
  44.     while (tests--)
  45.     {
  46.         cin>>l>>u;
  47.  
  48.         int brojac=0;
  49.  
  50.         for (int i=l;i<=u;i++)
  51.             if (special(i) && awesome(i)) brojac++;
  52.  
  53.         cout<<brojac<<endl;
  54.     }
  55.     return 0;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement