因吹思挺

IPSC2016_因吹思挺

趣味编程大赛XD

官方题解

考前拉倒诗兄 三金两条大腿一起来玩2333

然而因为我太困-.-提前睡了 早上起来发现rk300嘻嘻

Problem A

给出十个长度为4的字符串,求一个包含这十个字符串的一个串

  • easy: 串长度为42
  • hard: 串长度为39

42的直接输出在加两个就好了

39的 O(N2) 找一下对应的(代码在最下面)

Problem C

给出一段序列,求最小交换次数 的可能种类

题解

  • easy BFS找到sort到original的shortest path数量
  • hard 置换的统计数…递推上去

  • 诗兄: 找规律

    more than enough to guess the pattern, or to make a lookup in the Online Encyclopedia of IntegerSequences (OEIS). It turns out that for l ≥ 2 we have C(l) = ll2 . This can be computed quickly usingmodular exponentiation.Cayley’s formula

  • 发现一个神奇的找规律网站

Problem D (JS解析题)

给出一个页面,,要求我们玩命令指示点击游戏

九百多关,,通关console交上去

  • 把HTML页面下在本地
  • 发现并不是随机数
  • 做字符串命令解析

通过这次比赛发现存在压缩代码还原的软件…..

Problem G

给出一个字符串.求其中删去字符后包含的最大数字

  • easy 保留所有数字输出
  • hard 去除前导0(下面有代码XD)
//作为队内水题主力的我233
//A_Hard
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
using namespace std;

const int maxn = 10 + 5;
string str[maxn];
int suc = false,fr,bk;

int main()
{
    freopen("a2.in", "r", stdin);
    freopen("a2.out", "w", stdout);
    int T;
    scanf("%d",&T);
    while (T--) {
        for (int a = 0; a < 10; a++) {
            cin >> str[a];
        }
        suc = false;
        int pos = -1,del = 0;
        while (suc == false) {
            pos++;
            for (int k = 0; k < 10; k++) {
                if (k != pos) {
                    if (str[k][3] == str[pos][0]) {
                        bk = pos;
                        fr = k;
                        suc = true;
                        del = 1;
                        break;
                    }else if (str[k][2] == str[pos][0]
                              &&str[k][3] == str[pos][1])
                    {
                        bk = pos;
                        fr = k;
                        suc = true;
                        del = 2;
                        break;
                    }else if (str[k][1] == str[pos][0]
                              &&str[k][2] == str[pos][1]
                              &&str[k][3] == str[pos][2])
                    {
                        bk = pos;
                        fr = k;
                        suc = true;
                        del = 3;
                        break;
                    }
                    else if (str[k]== str[pos])
                    {
                        bk = pos;
                        fr = k;
                        suc = true;
                        del = 4;
                        break;
                    }
                }//暴力比较.
            }
        }
        cout << str[fr] ;
        for (int i = del; i < 4; i++) {
            cout << str[bk][i];
        }
        for (int i = 0; i < 10; i++) {
            if (i != fr && i != bk) {
                cout << str[i];
            }
        }
        del--;
        for (int i = 0; i < del; i++) {
            cout << "H" ;
        }
        cout << endl;
    }
    return 0;
}

//g hard 
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
using namespace std;
string a,ans;
int main()
{
    freopen("g2.in", "r", stdin);
    freopen("g2.out", "w", stdout);
    int T;
    scanf("%d",&T);
    while (T--) {
        cin >> a;
        ans = "";
        for (int i = 0; i < a.size(); i++) {
            if (a[i] >= '0' && a[i] <= '9') {
                ans += a[i];
            }
        }
        while (ans.size() > 1 && ans[0] == '0') {
            ans.erase(ans.begin());
        }
        cout << ans << endl;
    }
    return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值