generated from OPCODE-Open-Spring-Fest/template
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #178 from Jagpreet153/day_20_medium_Jagpreet153
- Loading branch information
Showing
1 changed file
with
41 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,41 @@ | ||
//write your code here | ||
//write your code here | ||
//Code by Jagpreet153 | ||
#include <bits/stdc++.h> | ||
using namespace std; | ||
|
||
int main() { | ||
long long res = 1; | ||
string b; | ||
cin >> b; | ||
vector<bool> z(10, true); | ||
int num0 = 0; | ||
int num = 0; | ||
if (b[0] == '?') | ||
res = 9; | ||
else if (b[0] - 'A' < 10 && b[0] - 'A' >= 0) | ||
{ | ||
res = 9; | ||
z[b[0] - 'A'] = false; | ||
num++; | ||
} | ||
for (int i = 1; i < b.size(); i++) | ||
{ | ||
if (b[i] == '?') | ||
num0++; | ||
else if (b[i] - 'A' < 10 && b[i] - 'A' >= 0) | ||
{ | ||
if (z[b[i] - 'A']) | ||
{ | ||
res *= 10 - num; | ||
num++; | ||
z[b[i] - 'A'] = false; | ||
} | ||
} | ||
} | ||
cout << res; | ||
for (int i = 0; i < num0; i++) { | ||
cout << "0"; | ||
} | ||
|
||
return 0; | ||
} |