SHARE
TWEET

Untitled

a guest Feb 24th, 2020 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <fstream>
  2.  
  3. using namespace std;
  4. ifstream f("produs2.in");
  5. ofstream g("produs2.out");
  6. long long i , n , p , nr , prod , j , a[1000002] ;
  7.  
  8. int main()
  9. {
  10.     f >> n >> p ;
  11.     for ( i = 1 ; i <= n ; i++ ) f >> a[i] ;
  12.     nr = 0 ;
  13.     i = 1 ;
  14.     j = 0 ;
  15.     prod = 1 ;
  16.     while ( j < n )
  17.     {
  18.         j++ ;
  19.         prod = prod * a[j] ;
  20.         if ( prod < p ) nr = nr + j - i + 1 ;
  21.         else {
  22.                while ( prod >= p ) { prod = prod / a[i] ; i++ ; }
  23.                nr=nr+j-i+1;
  24.              }
  25.     }
  26.     g << nr ;
  27.     return 0;
  28. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top