c++世界生存手册(启程——1)

致歉

上周因电脑原因导致无法更新,请原谅

故事

你慢慢睁开了双眼,发现来到自己到了一个陌生的地方。“额。。。头好痛”你突然想起了小D和小H,“那两人呢?”你开始观察四周,发现了一个密码锁,旁边还有一段文字“(ÒωÓױ)!密室逃脱?!不管了,要先从这里出去!”

题目

A Y G S U
D O M R A
C P F A S
X B O D G
W D Y P K
P R X W O

C B O P T
D O S B G
G T R A R
A P M M S
W S X N U
E F G H I

#输入错误便会立即爆炸
Σ(☉▽☉"神马鬼?我怎么什么也看不懂?对了!不是还有秘籍吗!
秘籍
找密码的规则:密码中左数第i个字母,必须在两个矩阵左数第i列中均出现。要求密码中,字典序第k小的密码,如果不存在,密码为"NO"。
真是秘籍在手,天下我有!
代码

#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int T,k;
bool found[7][128];
char x;
vector<char> can[7];
int last[7];
int main()
{
#ifdef local
    freopen("pro.in","r",stdin);
#endif
    scanf("%d",&T);
    while(T-->0)
    {
        memset(found,0,sizeof(found));
        for(int i=1;i<=5;i++) can[i].clear();
        cin>>k;
        for(int i=1;i<=6;i++)
            for(int j=1;j<=5;j++)
                found[j][cin>>x,x]=1;
        for(int i=1;i<=6;i++)
            for(int j=1;j<=5;j++)
                if(found[j][cin>>x,x])
                {
                    can[j].push_back(x);
                    found[j][x]=0;
                }
        for(int i=1;i<=5;i++) sort(can[i].begin(),can[i].end());
        last[5]=1;
        for(int i=4;i>=0;i--) last[i]=last[i+1]*can[i+1].size();
        if(k>last[0]) cout<<"NO"<<endl;
        else
        {
            for(int i=1;i<=5;i++)
            {
                int j=ceil((double)k/last[i])-1;
                cout<<can[i][j];
                k-=last[i]*j;
            }
            cout<<endl;
        }
    }
    return 0;
}

英文版

Apology

Excuse me for not updating last week due to computer reasons.

Story

Slowly you open your eyes and find yourself in a strange place. “Well… Your head hurts. “You suddenly think of little D and little H.” What about those two people? You start looking around and find a password lock with a text next to it. Room escape?! Anyway, you have to get out of here first!”

subject

A Y G S U
D O M R A
C P F A S
X B O D G
W D Y P K
P R X W O

C B O P T
D O S B G
G T R A R
A P M MS
W S X N U
E F G H I

#Input error will explode immediately!
( How can I not understand anything? By the way! Isn’t there a secret book?
Secret book
Rules for finding passwords: The left-hand letter in a password must appear in the left-hand column of both matrices. Require password, dictionary order k small password, if it does not exist, the password is “NO”.
It’s a secret book in hand. I have it all over the world!
Code

#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int T,k;
bool found[7][128];
char x;
vector<char> can[7];
int last[7];
int main()
{
#ifdef local
    freopen("pro.in","r",stdin);
#endif
    scanf("%d",&T);
    while(T-->0)
    {
        memset(found,0,sizeof(found));
        for(int i=1;i<=5;i++) can[i].clear();
        cin>>k;
        for(int i=1;i<=6;i++)
            for(int j=1;j<=5;j++)
                found[j][cin>>x,x]=1;
        for(int i=1;i<=6;i++)
            for(int j=1;j<=5;j++)
                if(found[j][cin>>x,x])
                {
                    can[j].push_back(x);
                    found[j][x]=0;
                }
        for(int i=1;i<=5;i++) sort(can[i].begin(),can[i].end());
        last[5]=1;
        for(int i=4;i>=0;i--) last[i]=last[i+1]*can[i+1].size();
        if(k>last[0]) cout<<"NO"<<endl;
        else
        {
            for(int i=1;i<=5;i++)
            {
                int j=ceil((double)k/last[i])-1;
                cout<<can[i][j];
                k-=last[i]*j;
            }
            cout<<endl;
        }
    }
    return 0;
}
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值