• Source
    1. #include <iostream>
    2. #include <math.h>
    3. #include <vector>
    4. using namespace std;
    5.  
    6. /* Ham tinh phu cho ban nao can ^^.
    7. int ktcp (long long u)
    8. {
    9. long long tmp =sqrt (u);
    10. if (tmp*tmp==u) return 1;
    11. else return 0;
    12. }
    13.  
    14. int ktXepTG (long long x)
    15. {
    16. long long denta = 1+8*x;
    17. long long tmp=sqrt (denta);
    18. if ((tmp*tmp)==denta && (-1+tmp)%2==0) return 1;
    19. return 0;
    20. }
    21. */
    22.  
    23. int main ()
    24. {
    25. /* Tinh truoc 10^9 so:
    26. vector <long long> v;
    27. for (long long u=2; u<=1000000000-1; u++)
    28. {
    29. if (ktcp (u)==1 && ktXepTG (u-1)==1) v.push_back (u);
    30. }
    31. */
    32. //Se co cac so t/m la:
    33. long long v[] = {4, 16, 121, 529, 4096, 17956, 139129, 609961, 4726276, 20720704, 160554241, 703893961}; //|| ^^ ||
    34. long long a, b;
    35. int t=0;
    36. while (1)
    37. {
    38. cin>>a>>b;
    39. if (a==0 && b==0) break;
    40. t++;
    41. long long k=0;
    42. for (int i=0; i<12; i++)
    43. {
    44. if (v[i]>a && v[i]<b) k++;
    45. }
    46. cout<<"Case "<<t<<": "<<k<<endl;
    47. }
    48. return 0;
    49. }