fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5. int testCases, amountOfNumbers;
  6. string text;
  7. cin >> testCases;
  8. while (testCases--)
  9. {
  10. cin >> amountOfNumbers >> text;
  11. int result = 1;
  12. int temp = 0;
  13. for (int i = 0; i < text.length(); i++)
  14. {
  15. if (text[i] == '?' && i > 0)
  16. {
  17. result *= 10;
  18. }
  19. else if (text[i] == '?' && i == 0)
  20. {
  21. result *= 9;
  22. }
  23. else if (text[i] != '?')
  24. {
  25. temp++;
  26. }
  27. }
  28. if (temp == amountOfNumbers)
  29. {
  30. result = 1;
  31. cout << result << endl;
  32. temp = 0;
  33. }
  34. else
  35. {
  36. cout << result << endl;
  37. }
  38. }
  39. }
Success #stdin #stdout 0.01s 5420KB
stdin
4
3 12?
5 1?2?3
3 123
3 ?23
stdout
10
100
1
9