Skip to content

Commit ce01fe2

Browse files
committed
project euler added
1 parent 9ffeafe commit ce01fe2

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#include <bits/stdc++.h>
2+
#define lli long long int
3+
using namespace std;
4+
5+
6+
int main() {
7+
int n;
8+
cin>>n;
9+
vector <string> v1;
10+
string data;
11+
for(int i=0; i<n; i++)
12+
{
13+
cin>>data;
14+
v1.push_back(data);
15+
}
16+
sort(v1.begin(), v1.end());
17+
map <string, pair<lli, lli> > mp1;
18+
for(int i=0; i<v1.size(); i++)
19+
{
20+
lli place = i+1;
21+
lli sumi = 0;
22+
for(int j=0; j<v1[i].length(); j++)
23+
sumi += (int)((v1[i][j]-'A')+1);
24+
mp1[v1[i]] = {place, sumi};
25+
}
26+
int q;
27+
cin>>q;
28+
while(q--)
29+
{
30+
cin>>data;
31+
cout<<(lli)((lli)(mp1[data].first)*(lli)(mp1[data].second))<<endl;
32+
}
33+
return 0;
34+
}

0 commit comments

Comments
 (0)