Advertisement
rishu110067

Untitled

Feb 1st, 2024
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | Source Code | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define ll long long
  5. const ll M = 1e9 + 7;
  6. const ll inv = 333333336;
  7.  
  8. ll pow(ll x, ll y) {
  9. if(y == 0) return 1;
  10. ll res = 1;
  11. while(y > 0) {
  12. if(y % 2 == 0) {
  13. x = x * x % M;
  14. y /= 2;
  15. }
  16. else {
  17. res = res * x % M;
  18. y--;
  19. }
  20. }
  21. return res;
  22.  
  23. }
  24.  
  25.  
  26. int main() {
  27. int tc; cin >> tc;
  28. while(tc--) {
  29. ll x; cin >> x;
  30. cout << pow(10,x) * inv % M << endl;
  31. }
  32. return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement