Advertisement
artur99

Untitled

Feb 14th, 2017
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.55 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main(){
  6.     int i, j, d1, d2, nr1, nr2, nrdiv,maxdiv=-1,a,b;
  7.     cin>>a>>b;
  8.     nr1=nr2=0;
  9.     for(i=a;i<=b;i++){
  10.         nrdiv = 0;
  11.         if(i%2 == 0) nrdiv++;
  12.         for(j=2;j<=i/2;j++){
  13.             if(i % j == 0 && j % 2 == 0){
  14.                 nrdiv++;
  15.             }
  16.         }
  17.         if(nrdiv > maxdiv){
  18.             nr1 = nr2 = i;
  19.             maxdiv = nrdiv;
  20.         }else if(nrdiv == maxdiv){
  21.             nr2 = i;
  22.         }
  23.  
  24.     }
  25.     cout<<maxdiv<<" "<<nr1<<" "<<nr2;
  26.     return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement