Advertisement
Guest User

Untitled

a guest
Feb 24th, 2020
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement