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
- #include <bits/stdc++.h>
- using namespace std;
- int prime(int v)
- {
- for(int i=2; i<=sqrt(v); i++)
- {
- if(v%i==0)
- return false;
- }
- return true;
- }
- int main()
- {
- int t,d,m,n;
- cin>>t;
- while(t--)
- {
- cin>>d;
- m=1+d;
- while(prime(m)==false)
- m++;
- n=m+d;
- while(prime(n)==false)
- n++;
- cout<<m*n<<endl;
- }
- }
No comments