SHARE
    TWEET
    AlexAvram

    Untitled

    Nov 26th, 2022
    91
    0
    Never
    Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
    C++ 1.23 KB | None | 0 0
    1. #include <iostream>
    2. #include <fstream>
    3. #include <math.h>
    4. using namespace std;
    5. ifstream f("clatite.in");
    6. ofstream g("clatite.out");
    7. bool prim(int a)
    8. {
    9. if ((a%2==0 && a!=2) || a<2)
    10. return 0;
    11. else
    12. {
    13. int d;
    14. for (d=3; d*d<=a; d+=2)
    15. if (a%d==0)
    16. return 0;
    17. }
    18. return 1;
    19. }
    20. bool pp_cc(int a)
    21. {
    22. int x, y;
    23. x=sqrt(a);
    24. if (x*x==a)
    25. return 1;
    26. y=cbrt(a);
    27. if (y*y*y==a)
    28. return 1;
    29. return 0;
    30. }
    31. int sumdiv(int a)
    32. {
    33. int d;
    34. long long sum=0;
    35. for (d=1; d*d<a; ++d)
    36. if (a%d==0)
    37. sum+=d+(a/d);
    38. if (d*d==a)
    39. sum+=d;
    40. return sum-a;
    41. }
    42. int main()
    43. {
    44. int n, m;
    45. int cioco=0, gem=0, inghe=0, zah=0, sim=0;
    46. f>>n>>m;
    47. if (n>m)
    48. swap(n,m);
    49. int i, j;
    50. for (i=n; i<=m; ++i)
    51. {
    52. if (prim(i)==1)
    53. ++cioco;
    54. else if (pp_cc(i)==1)
    55. ++gem;
    56. else if (sumdiv(i)==i)
    57. ++inghe;
    58. else if (i%2==0)
    59. ++zah;
    60. else if (i%2==1)
    61. ++sim;
    62. }
    63. g<<m-n+1<<'\n'<<cioco<<" "<<gem<<" "<<inghe<<" "<<zah<<" "<<sim<<'\n';
    64. f.close();
    65. g.close();
    66. return 0;
    67. }
    Advertisement
    Add Comment
    Please, Sign In to add comment
    Public Pastes
    We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
    Not a member of Pastebin yet?
    Sign Up, it unlocks many cool features!

    AltStyle によって変換されたページ (->オリジナル) /