fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define M 1000000007
  4.  
  5. long long power(int a, int b) {
  6. long long re = 1;
  7. if(b == 0) return 1;
  8.  
  9. if(b % 2) return (a * power(a, b - 1)) % M;
  10. else { re = power(a, b / 2); return ((re % M) * (re % M)) % M; }
  11. }
  12.  
  13. int main(){
  14. int t;cin >> t;
  15. while(t--) {
  16. int n, s = 1, c = 0; cin >> n;
  17. vector<int> a(n);
  18. for(int &i : a) {
  19. cin >> i;
  20. if(i != 0) s = (s * (i % M)) % M;
  21. else c++;
  22. }
  23.  
  24. for(int i : a) {
  25. if(c == 0) {
  26. cout << power(s, M - 2) << ' ';
  27. cout << ((s * power(s, M - 2)) % M);
  28. }
  29. else if( c == 1 ) {
  30. if(i == 0) cout << s;
  31. else cout << "0";
  32. }
  33. else {
  34. cout << '0';
  35. }
  36. cout << ' ';
  37. }
  38. cout << '\n';
  39. }
  40. return 0;
  41. }
Success #stdin #stdout 0.01s 5520KB
stdin
1
4
100000 100000 100000 100000
stdout
-968266675 1 -968266675 1 -968266675 1 -968266675 1