yuan2795 @ 2024-10-28 13:29:30
#include<bits/stdc++.h>
using namespace std;
string s;
string yz[21]={"another","one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen","twenty"};
string wt[8];
string dot;
string su[22];
int cnt=0;
int main()
{
for(int i=1;i<=6;i++)
{
cin>>wt[i];
}
cin>>dot;
for(int i=1;i<=6;i++)
{
for(int j=0;j<=20;j++)
{
if(wt[i]==yz[j]&&wt[i]=="another")
{
cnt++;
su[cnt]="1";
}
if(wt[i]==yz[j]&&wt[i]!="another")
{
cnt++;
su[cnt]=to_string(j*j%100);
}
}
}
for(int i=1;i<=cnt;i++)
{
if(su[i].size()==1)
{
su[i]='0'+su[i];
}
}
sort(su+1,su+cnt+1);
string ss;
int flag=1;
for(int i=1;i<=cnt;i++)
{
ss=ss+su[i];
}
int kk;
for(int i=0;i<ss.size();i++)
{
if(flag==0&&ss[i]=='0'&&ss[i+1]!='0')
{
kk=i;
break;
}
}
string g="";
for(int i=kk+1;i<ss.size();i++)
{
g=g+ss[i];
}
cout<<g;
return 0;
}
by yuan2795 @ 2024-10-29 12:46:05
通过了
蒟蒻再次强调:
1.要特判没有数字的情况
2.当特判a,both……等不正规的单词是不要放在双层循环(可以看我错误代码),要放在外层
3.非正规的都是要的!!
by yuan2795 @ 2024-10-29 12:46:54
#include<bits/stdc++.h>
using namespace std;
string s;
string yz[21]={"another","one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen","twenty"};
string yt[21]={"a","both"};
string yl[21]={"first","second","third"};
string wt[8];
string dot;
string su[22];
int cnt=0;
int main()
{
for(int i=1;i<=6;i++)
{
cin>>wt[i];
}
cin>>dot;
for(int i=1;i<=6;i++)
{
for(int j=0;j<=20;j++)
{
if(wt[i]==yz[j]&&wt[i]=="another")
{
cnt++;
su[cnt]="1";
}
if(wt[i]==yz[j]&&wt[i]!="another")
{
cnt++;
su[cnt]=to_string(j*j%100);
}
}
if(wt[i]==yt[0])//注意放在外层
{
cnt++;
su[cnt]=to_string(1);
}
if(wt[i]==yt[1])
{
cnt++;
su[cnt]=to_string(4);
}
if(wt[i]==yl[0])
{
cnt++;
su[cnt]=to_string(1);
}
if(wt[i]==yl[1])
{
cnt++;
su[cnt]=to_string(4);
}
if(wt[i]==yl[2])
{
cnt++;
su[cnt]=to_string(9);
}
}
if(cnt==0)//特判
{
cout<<0;
return 0;
}
for(int i=1;i<=cnt;i++)
{
if(su[i].size()==1)
{
su[i]='0'+su[i];
}
}
sort(su+1,su+cnt+1);
string ss;
int flag=1;
for(int i=1;i<=cnt;i++)
{
ss=ss+su[i];
}
int kk;
for(int i=0;i<ss.size();i++)
{
if(flag==0&&ss[i]=='0'&&ss[i+1]!='0')
{
kk=i;
break;
}
}
string g="";
for(int i=kk+1;i<ss.size();i++)
{
g=g+ss[i];
}
cout<<g;
return 0;
}