XSean @ 2022-08-17 16:50:34
(3)把这些两位数按数位排成一行,组成一个新数,如果开头为 0,就去 0。
(4)找出所有排列方法中最小的一个数,即为密码。
by XSean @ 2022-08-17 16:51:27
上面两句话看不懂
by Sator1 @ 2022-08-17 16:57:46
(3):把所有两位数组合在一起,写成一个数字,去除前导零,就是去掉数字前面多余的0
(4):(3)里面有多种组合方式,答案要求组合后的数字最小
by Sator1 @ 2022-08-17 17:00:10
比如(3)中有3个数字 01 12 34
(3)可以组合成011234去除前导0变成11234
也可以组合120134,123401等等
by caramel_qwq @ 2022-08-17 17:04:31
@Sean_xzx
by XSean @ 2022-08-17 17:07:40
@BCNT 这个题解26~31行什么意思
#include<iostream>
#include<algorithm>
using namespace std;
string yw[30]={"","one","two","three","four","five","six","seven",
"eight","nine","ten","elven","twelve","thirteen","fourteen","fifteen",
"sixteen","seventeen","eighteen","nineteen","twenty","a","both",
"another","first","second","third"};
int sz[30]={0,1,4,9,16,25,36,49,64,81,0,21,44,69,96,25,56,89,24,61,0,
1,4,1,1,4,9};
int k;
int a[10];
int main()
{
for(int i=1;i<=6;i++)
{
string x;
cin>>x;//直接用变量读就行了
for(int j=1;j<=26;j++)//26种英文数字
if(yw[j]==x)
{a[++k]=sz[j];break;}//k记录有几个英文数字
}
if(k==0){cout<<0<<endl;return 0;}//先判断一下句子中有没有英文数字
sort(a+1,a+k+1);//排序//26
for(int i=1;i<=k;i++)
{
if(i!=1&&a[i]<10)cout<<0;//补0
cout<<a[i];
}//31
cout<<endl;
return 0;
}
by xingcode @ 2022-11-27 14:38:51
#include<bits/stdc++.h>
using namespace std;
int s,l=1;
int t[10];
string a,b;
int main()
{
for(int i=1;i<=6;i++)
{
cin>>b;
if(b=="one"||b=="another"||b=="first"||b=="a")
{
t[l]=1;
l++;
}
else if(b=="two"||b=="both"||b=="second")
{
t[l]=4;
l++;
}
else if(b=="three"||b=="third")
{
t[l]=9;
l++;
}
else if(b=="four")
{
t[l]=16;
l++;
}
else if(b=="five")
{
t[l]=25;
l++;
}
else if(b=="six")
{
t[l]=36;
l++;
}
else if(b=="seven")
{
t[l]=49;
l++;
}
else if(b=="eight")
{
t[l]=64;
l++;
}
else if(b=="nine")
{
t[l]=81;
l++;
}
else if(b=="eleven")
{
t[l]=21;
l++;
}
else if(b=="twelve")
{
t[l]=44;
l++;
}
else if(b=="thirteen")
{
t[l]=69;
l++;
}
else if(b=="fourteen")
{
t[l]=96;
l++;
}
else if(b=="fifteen")
{
t[l]=25;
l++;
}
else if(b=="sixteen")
{
t[l]=56;
l++;
}
else if(b=="seventeen")
{
t[l]=89;
l++;
}
else if(b=="eighteen")
{
t[l]=24;
l++;
}
else if(b=="nineteen")
{
t[l]=61;
l++;
}
}
sort(t+1,t+l);
long long s=0;
for(int i=1;i<l;i++)
{
s=s*100+t[i];
}
cout<<s;
return 0;
}
by b1acat @ 2022-11-28 21:10:33
@BCNT 没太懂例题里的答案25 和4 的话254不是更小吗。为什么是425
by zzh25951853 @ 2022-12-02 15:53:49
@b1acat 按照题里的意思是25和04排列,那就应该是2504>0425,而不是254