codeforces 1474B. Different Divisors solution

 Solution in C++:

 ///La ilaha illellahu muhammadur rasulullah

///******Bismillahir-Rahmanir-Rahim******///

///AH Tonmoy

///Department of CSE,23rd batch

    ///Islamic University,Bangladesh

    1. #include <bits/stdc++.h>
    2. using namespace std;
    3. int prime(int v)
    4. {
    5. for(int i=2; i<=sqrt(v); i++)
    6. {
    7. if(v%i==0)
    8. return false;
    9. }
    10. return true;
    11. }
    12. int main()
    13. {
    14. int t,d,m,n;
    15. cin>>t;
    16. while(t--)
    17. {
    18. cin>>d;
    19. m=1+d;
    20. while(prime(m)==false)
    21. m++;
    22. n=m+d;
    23. while(prime(n)==false)
    24. n++;
    25. cout<<m*n<<endl;
    26. }
    27. }

    No comments

    Most View Post

    Recent post

    Codeforces Round 971 (Div. 4) 2009C. The Legend of Freya the Frog Solution

      Problem Link    https://codeforces.com/contest/2009/problem/C S olution in C++: /// Author : AH_Tonmoy #include < bits / stdc ++. h ...

    Powered by Blogger.