fork download
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4. main(){
  5. int T,N,L,R;
  6. long long M;
  7. cin>>N;
  8. vector<int> v(N+1);
  9. for(int i=1;i<=N;i++){
  10. cin>>v[i];
  11. }
  12. cin>>T;
  13. while(T--){
  14. cin>>L>>R>>M;
  15. int res=1;
  16. for(int i=L;i<=R;i++){
  17. res=(res*v[i])%M;
  18. }
  19. cout<<res<<endl;
  20. }
  21. }
  22.  
Success #stdin #stdout 0s 16064KB
stdin
Standard input is empty
stdout
1
1