langzhu_3238 @ 2023-04-01 08:23:37
#include<iostream>
#include<map>
#include<algorithm>
using namespace std;
int main()
{
map<string,int> q;
int i,ans,t=1,a[10];
string s;
q["one"]=1;q["two"]=2;q["three"]=3;q["four"]=4;q["five"]=5;q["six"]=6;q["seven"]=7;q["eight"]=8;q["nine"]=9;q["ten"]=10;
q["eleven"]=11;q["twelve"]=12;q["thirteen"]=13;q["fourteen"]=14;q["fifteen"]=15;q["sixteen"]=16;q["seventeen"]=17;q["eighteen"]=18;q["nineteen"]=19;q["twenty"]=20;
q["a"]=1;q["both"]=2;q["another"]=1;q["first"]=1;q["second"]=2;q["third"]=3;
for(i=1;i<=6;i++)
{
cin>>s;
if(q[s])
{
ans=(q[s]*q[s])%100;
if(ans==0) continue;
else
{
a[t]=ans;
t++;
}
}
}
cin>>s;
sort(a+1,a+t);
cout<<a[1];
for(i=2;i<t;i++)
{
if(a[i]<10) cout<<0<<a[i];
else cout<<a[i];
}
}
第三个测试点过不了
by cat_lover1 @ 2023-04-15 23:17:58
@langzhu_3238 第一个数是10,第二个数是20,你这样的话第一个0你20就输出了吧?这是我能想到的一个bug
by Destroyer_S @ 2023-09-09 14:13:44
一下为我的代码:
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
short a[1000000];
int main(){
short n=1;
string b;
while(cin>>b)
{
if(b=="one"||b=="a"||b=="another"||b=="first")
{
a[n++]=1;
}
else if(b=="two"||b=="second"||b=="both")
{
a[n++]=4;
}
else if(b=="three"||b=="third")
{
a[n++]=9;
}
else if(b=="four")
{
a[n++]=16;
}
else if(b=="five")
{
a[n++]=25;
}
else if(b=="six")
{
a[n++]=36;
}
else if(b=="seven")
{
a[n++]=49;
}else if(b=="eight")
{
a[n++]=64;
}else if(b=="nine")
{
a[n++]=81;
}else if(b=="eleven")
{
a[n++]=21;
}else if(b=="twelve")
{
a[n++]=44;
}else if(b=="thirteen")
{
a[n++]=69;
}else if(b=="fourteen")
{
a[n++]=96;
}else if(b=="fifteen")
{
a[n++]=25;
}else if(b=="sixteen")
{
a[n++]=56;
}else if(b=="seventeen")
{
a[n++]=89;
}else if(b=="eighteen")
{
a[n++]=24;
}else if(b=="nineteen")
{
a[n++]=61;
}
}
sort(a+1,a+n);
for(int i=1;i<n;i++)
{
if(a[i]!=0)
{
if(a[i]/10==0&&i!=1)
{
cout<<0<<a[i];
}else
{
cout<<a[i];
}
}
}
if(n==1)
{
cout<<0;
}
return 0;
}