1350A - Orac and Factors


  1. 1350A - Orac and Factors


  1. #include<iostream>
  2. using namespace std;
  3. int main(){
  4. long n,k;
  5. int t,i;
  6. cin>>t;
  7. while(t--){
  8. long c=0;
  9. cin>>n>>k;
  10. if(n%2==0){
  11. n=n+2*k;
  12. cout<<n<<endl;
  13. }
  14.  
  15. else{
  16. for(int j=2;j<=n;j++){
  17. if(n%j==0) 
  18. {c=j;
  19. break;}
  20. }
  21. c=c+n;

  22. c=c+2*(k-1);

  23. cout<<c<<endl;
  24. }

  25. }
  26. return 0;}

Comments

Popular posts from this blog

Codeforce Problem 1703A. YES or YES?

1535A. Fair Playoff

Aptitude test assistant programmer 2018