problem with codeforces compiler .

Правка en2, от 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 .

Теги casting, log, algorithms, compilers

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en2 Английский Steven-_-AbuAlkhair 2022-02-26 13:23:11 26
en1 Английский Steven-_-AbuAlkhair 2022-02-26 12:18:26 692 Initial revision (published)