G.cpp 503 B

123456789101112131415161718192021222324252627282930
  1. #include <iostream>
  2. using namespace std;
  3. using ll=long long;
  4. int main() {
  5. int a[10] = {1};
  6. for (int i = 1; i <= 9; i++) {
  7. a[i] = i * a[i - 1];
  8. }
  9. int t;
  10. cin >> t;
  11. while (t--) {
  12. int x;
  13. cin >> x;
  14. for (int i = 9; i >= 1; i--) {
  15. if (x >= a[i]) {
  16. x -= a[i];
  17. }
  18. }
  19. if (x == 0) {
  20. cout << "Yes" << endl;
  21. } else {
  22. cout << "No" << endl;
  23. }
  24. }
  25. return 0;
  26. }