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 925 (Div. 3) 1931D. Divisible Pairs Solution

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

    Powered by Blogger.