problem with codeforces compiler .

Revision en2, by Steven-_-AbuAlkhair, 2022-02-26 13:23:11

in this code

main (){
    
  int n  ; cin >> n  ;
  double  arr[n] ;
  for(int i = 0 ; i < n ; i++)cin >>arr[i] ;
        int cnt  = 0; 
  for(int i = 0 ;  i < n-1  ;  i++)
  
  for(int j = i +1 ; j < n ; j ++ )
   {
       double l = log10(arr[i]+arr[j])/log10(2);
       int r = l ; 
      if(l-(double)r==0) cnt++ ;
   }
   cout<<cnt ; 
  }

when input is

4 7 3 2 1 it gives cnt = 1 because the the compiler of codeforces when arr[i] =7 and arr[j]=1 gives l=3 but r=2 ! (it dosent happen in other compilers)

even this similar code gives wa i think because of the same reason 147734731 thanks .

Tags casting, log, algorithms, compilers

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English Steven-_-AbuAlkhair 2022-02-26 13:23:11 26
en1 English Steven-_-AbuAlkhair 2022-02-26 12:18:26 692 Initial revision (published)