样例是不是有点问题?

P1603 斯诺登的密码

嚯呀嚯呀 @ 2017-06-13 21:29:51

题目让我们找所有排列里面最小的一种输出

为什么不输出254而是425呢?

254不是比425小吗?


by 嚯呀嚯呀 @ 2017-06-13 21:40:56

已经会啦,谢谢各位神犇


by bh1234666 @ 2017-10-22 17:04:57

???


by bh1234666 @ 2017-10-22 17:05:14

好像是有问题啊


by bh1234666 @ 2017-10-22 17:06:09

@worcher


by bh1234666 @ 2017-10-22 17:07:12

#include<cstdio>
#include<cstring>
using namespace std;
char a[25][15]={"","one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen ","eighteen","nineteen","twenty"};
char x[100];
int n[10];
int main()
{
    int i,j,k=0;
    for(i=0;i<=5;i++)
    {
        scanf("%s",x);
        for(j=1;j<=20;j++)
            if(!strcmp(a[j],x)&&j*j%100)
            {
                n[k]=j*j%100;
                k++;
            }
    }
    for(i=0;i<k;i++)
        for(j=i+1;j<k;j++)
        {
            bool ii=0,jj=0;
            if(n[i]<10)
            {
                n[i]*=11;
                ii=1;
            }
            if(n[j]<10)
            {
                n[j]*=11;
                jj=1;
            }
            if(n[i]>n[j])
            {
                int h;
                if(ii==1) n[i]/=11;
                if(jj==1) n[j]/=11;
                h=n[i];
                n[i]=n[j];
                n[j]=h;
            }
            else
            {
                if(ii==1) n[i]/=11;
                if(jj==1) n[j]/=11;
            }
        }
    for(i=0;i<k;i++)
        printf("%d",n[i]);
    return 0;
}

by bh1234666 @ 2017-10-22 17:09:25

按描述是这样的吧


|