求助,第四个点过不去!

P1603 斯诺登的密码

HygoK67 @ 2017-12-04 21:44:52

如题:求助,第四个点过不去!

#include<bits/stdc++.h>
using namespace std;
struct word
{
    string enter;
    string number; 
    int qwq;
} w[7];
map <string,int> num;
string ans = "";
bool cmp(word a,word b)
{
    return a.qwq < b.qwq;
}
int main()
{
    for(int i = 1;i <= 6;i++)
    {
        w[i].qwq = 0;
        w[i].number = "0";
    }
    for(int i = 1;i <= 6;i++)
    {
        cin >> w[i].enter;
    }
    num.insert( pair<string,int> ("one",1) );
    num.insert( pair<string,int> ("two",2) );
    num.insert( pair<string,int> ("three",3) );
    num.insert( pair<string,int> ("four",4) );
    num.insert( pair<string,int> ("five",5) );
    num.insert( pair<string,int> ("six",6) );
    num.insert( pair<string,int> ("seven",7) );
    num.insert( pair<string,int> ("eight",8) );
    num.insert( pair<string,int> ("nine",9) );
    num.insert( pair<string,int> ("ten",10) );
    num.insert( pair<string,int> ("eleven",11) );
    num.insert( pair<string,int> ("twelve",12) );
    num.insert( pair<string,int> ("thirteen",13) );
    num.insert( pair<string,int> ("fourteen",14) );
    num.insert( pair<string,int> ("fifteen",15) );
    num.insert( pair<string,int> ("sixteen",16) );
    num.insert( pair<string,int> ("seventeen",17) );
    num.insert( pair<string,int> ("nineteen",19) );
    num.insert( pair<string,int> ("twenty",20) );
    num.insert( pair<string,int> ("eighteen",18) );
    num.insert( pair<string,int> ("a",1) );
    num.insert( pair<string,int> ("both",2) );
    num.insert( pair<string,int> ("anothor",1) );
    num.insert( pair<string,int> ("first",1) );
    num.insert( pair<string,int> ("second",2) );
    num.insert( pair<string,int> ("third",3) );
    for(int i = 1;i <= 6;i++)
    {
        if( num.find(w[i].enter) == num.end() )
        {
            continue;
        }
        else
        {
            int x = num[w[i].enter];
            x = x * x;
            x = x % 100;
            w[i].qwq = x;
            string k = "";
            if( (x / 10)  > 1 )
            {
                k += (x / 10) + 48;
                k += (x % 10) + 48;
            }
            else
            {
                k += "0";
                k += (x % 10) + 48;
            } 
            w[i].number = k;
        }
    }
    sort(w,w+7,cmp);
    for(int i = 1;i <= 6;i++)
    {
        ans += w[i].number;
    }
    int cnt;
    bool zeee = 1;
    for(cnt = 0;cnt <= 5;cnt++)
    {
        if(ans[cnt] == '0')
        {
            continue;
        }
        else if(ans[cnt] != '0')
        {
            zeee = 0;
            break;
        }
    }
    for(;cnt <= ans.size() - 1;cnt++)
    {
        cout << ans[cnt];
    }
    if(zeee == 1)
    {
        cout << 0;
    }
    return 0;
}

by HygoK67 @ 2017-12-04 21:45:24

第四个点过不去!


by HygoK67 @ 2017-12-05 11:33:02

求第四个点数据


by 望天树 @ 2018-01-22 13:04:10

one two three four five six .


by 望天树 @ 2018-01-22 13:04:21

10409162536


by Explorer_CYC @ 2018-02-20 20:53:14

#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<iostream>
using namespace std;
struct gg{
    string s;
    int k;
}f[26];
int top=0;
string b[20],res[20];
inline int read()
{
    int t=1,data=0;
    char ch=0;
    while(ch!='-'&&!isdigit(ch)) ch=getchar();
    if(ch=='-') t=-1,ch=getchar();
    while(isdigit(ch)) data=data*10+ch-48;
    return data*t;
} 
inline void pre()
{
    for(int i=1;i<=20;i++)
    f[i].k=i;

    f[1].s="one";
    f[2].s="two";
    f[3].s="three";
    f[4].s="four";
    f[5].s="five";
    f[6].s="six";
    f[7].s="seven";
    f[8].s="eight";
    f[9].s="nine";
    f[10].s="ten";
    f[11].s="eleven";
    f[12].s="twelve";
    f[13].s="thirteen";
    f[14].s="fourteen";
    f[15].s="fifteen";
    f[16].s="sixteen";
    f[17].s="seventeen";
    f[18].s="eighteen";
    f[19].s="nineteen";
    f[20].s="twenty";

    f[0].k=1;  f[0].s="a";
    f[21].k=2;  f[21].s="both";
    f[22].k=1;  f[22].s="another";
    f[23].k=1;  f[23].s="first";
    f[24].k=2;  f[24].s="second";
    f[25].k=3;  f[25].s="third";
}
inline string turn(int k)
{
    string s;
    int lwd=k*k%100;
    s.push_back(lwd/10+'0');
    s.push_back(lwd%10+'0');
    return s;
}
inline bool cmp(string a,string b)
{
    return a+b<b+a;
}
int main()
{
    ios::sync_with_stdio(false);
    long long ans=0;
    char ch;
    for(int i=0;i<6;i++)
        cin>>b[i];
//  ch=getchar();
    pre();

    for(int i=0;i<6;i++)
        for(int j=0;j<26;j++)
            if(b[i]==f[j].s) res[++top]=turn(f[j].k);

    sort(res+1,res+1+top,cmp);

    for(int i=1;i<=top;i++)
        ans=ans*100+(res[i][0]-'0')*10+(res[i][1]-'0');

    printf("%lld",ans);
    return 0;
}

stm爆int。。。


by Haishu @ 2018-03-03 16:33:59

@战术目镜 你的another好像拼错了。。


by doingforemmmm @ 2018-07-22 00:44:57

我也醉醉的,站了半天没有找到错误。 结果原来是int不够大, 我是把每个数*100再累加的。改成long就好了。 给测试数据的都是好人啊 ==


by cp1227 @ 2021-10-04 08:48:19

是不是爆了


|