fork(2) download
  1. #include <iostream>
  2. #include <cstdio>
  3. using namespace std;
  4. int main()
  5. {
  6. unsigned long long x, y, p, q, r, z, i;
  7. unsigned long long a[100000];
  8. scanf ("%llu", &x);
  9. for (i = 1; i <= x; ++i)
  10. {
  11. scanf ("%llu", &a[i]);
  12. }
  13. scanf ("%llu", &y);
  14. for (y; y > 0; --y)
  15. {
  16. z = 1;
  17. scanf ("%llu%llu%llu", &p, &q, &r);
  18. for (p; p <= q; ++p)
  19. {
  20. z = z * a[p];
  21. }
  22. printf ("%llu\n", z % r);
  23. }
  24.  
  25. return 0;
  26. }
Success #stdin #stdout 0s 4004KB
stdin
5
1 2 3 4 5
4
1 2 3
2 3 4
1 1 1
1 5 1000000000
stdout
2
2
0
120