锘??xml version="1.0" encoding="utf-8" standalone="yes"?>
濡傚浘錛屾瘡鏉¤礬寰勪笂淇濆瓨涓涓瓧姣嶏紝浠庢牴鑺傜偣寮濮嬭繘琛宒fs錛屾瘡閬嶅巻鍒頒竴涓爣璁拌妭鐐癸紙鍥句腑鐨勭孩鐐癸級錛屼粠鏍硅妭鐐瑰埌褰撳墠鑺傜偣璺緞涓婃墍鏈夊瓧姣嶈繛璧鋒潵鍗充負涓涓崟璇?/span>
涓婂浘涓瓨鍌ㄤ簡 abc, abcd, b, bcd, efg, hij.
瀵逛簬Trie鏍戜富瑕佹湁涓夌鎿嶄綔錛?/span>
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 492 Accepted Submission(s): 408
ACM MID CENTRAL REGIONAL PROGRAMMING CONTEST ACN A C M ABC BBC #
46 650 4690 49 75 14 15
#include <iostream>
#include <cstdio>
#include <cstring>
int main()
{
char str[260];
int ans = 0;
while( gets(str) && str[0] != '#' )
{
ans = 0;
int len = strlen(str);
for( int i = 0; i < len; i++ )
{
if( str[i] == ' ' )
continue;
else
ans += ( str[i] - 64 ) * ( i + 1 );
}
std::cout << ans << std::endl;
}
return 0;
}

/*****************
瀛楃涓插鐞?br />
紼沖畾鎺掑簭
******************/
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
struct DNA
{
int pos;
int cnt;
string str;
};
bool cmp(const DNA &a, const DNA &b)
{
if (a.cnt != b.cnt)
{
return a.cnt < b.cnt;
}
else
{
return a.pos < b.pos;
}
}
int main()
{
int n, m, count;
DNA ans[110];
string str;
cin >> n >> m;
for (int i = 0; i < m; i++)
{
cin >> str;
count = 0;
for (int j = 0; j < n - 1; j++)
for (int k = j + 1; k < n; k++)
if (str[j] > str[k]) count++;
ans[i].str = str;
ans[i].cnt = count;
ans[i].pos = i;
}
sort(ans, ans + m, cmp);
for (int i = 0; i < m; i++)
cout << ans[i].str << endl;
return 0;
}
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
const int maxn = 20000;
const int MAXN = 100000+10;
using std :: string;
using std :: cout;
using std :: endl;
int main()
{
string ans[MAXN];
char tel[maxn];
char store[maxn];
int n;
bool ok;
while(~ scanf("%d",&n))
{
ok = false;
int count = 0;
while(n--)
{
scanf("%s",tel);
int j;
for(int i = 0,j = 0; tel[i] != '\0'; i++)
{
if(tel[i]-'0'>=0&&tel[i]-'0'<=9)
store[j++] = tel[i];
else if(tel[i] != '-' && j != 3 )
{
//ans[count]+='2';
if(tel[i]=='A'||tel[i]=='B'||tel[i]=='C')
store[j++] = '2';
else if(tel[i]=='D'||tel[i]=='E'||tel[i]=='F')
store[j++] = '3';
else if(tel[i]=='G'||tel[i]=='H'||tel[i]=='I')
store[j++] = '4';
else if(tel[i]=='J'||tel[i]=='K'||tel[i]=='L')
store[j++] = '5';
else if(tel[i]=='M'||tel[i]=='N'||tel[i]=='O')
store[j++] = '6';
else if(tel[i]=='P'||tel[i]=='R'||tel[i]=='S')
store[j++] = '7';
else if(tel[i]=='T'||tel[i]=='U'||tel[i]=='V')
store[j++] = '8';
else if(tel[i]=='W'||tel[i]=='X'||tel[i]=='Y')
store[j++] = '9';
}
if( j==3 ) store[j++]='-';
}
ans[count++] = store;
}
std :: sort(ans,ans+count);
int ans_count;
for(int i = 0; i < count; i++)
{
ans_count = 1;
for(int j = i + 1; j < count; j++)
{
if(ans[j]==ans[i]) ans_count++;
else break;
}
if(ans_count > 1)
{
ok = true;
cout << ans[i] << " " << ans_count << endl;
i+=(ans_count-1);
}
}
if(!ok) cout << "No duplicates." << endl;
//for(int i = 0; i <count; i++)
//std :: cout << ans[i] << std :: endl;
}
return 0;
}