zoukankan      html  css  js  c++  java
  • 【郑轻邀请赛 B】base64解密

    【题目链接】:https://acm.zzuli.edu.cn/zzuliacm/problem.php?id=2128

    【题意】

    【题解】

    把密文;
    在表中找到每个字符对应的数字;
    然后转换成相应的二进制;
    如果不足6位就在二进制的前面补零补到6位;
    然后每个字符6个二进制6个二进制地排在一起;
    然后8位8位地输出;
    ->最后可以得到”要你输入一个整数x,然后输出x%2017”;

    【Number Of WA

    0

    【完整代码】

    #include <bits/stdc++.h>
    using namespace std;
    #define rep1(i,x,y) for (int i = x;i <= y;i++)
    #define LL long long
    
    map <char,int> dic;
    string s,temp;
    int a[20],tot,x;
    
    string cl(int x)
    {
        string d = "";
        while (x)
        {
            d=char((x&1)+'0')+d;
            x>>=1;
        }
        while (int(d.size())<6) d='0'+d;
        return d;
    }
    
    char out()
    {
        int d = 0;
        for (int now = 1,i = 8;i>=1;i--)
        {
            d+=a[i]*now;
            now<<=1;
        }
        char t = d;
        return t;
    }
    
    int main()
    {
        //freopen("D:\rush.txt","r",stdin);
        for (char key = 'A';key<='Z';key++)
            dic[key]=key-'A';
        for (char key = 'a';key<='z';key++)
            dic[key]=key-'a'+26;
        for (char key = '0';key<='9';key++)
            dic[key]=key-'0'+52;
        dic['+']=62,dic['/']=63;
        //cin >> s;
        s="d2hhdCBpcyB0aGUgcmVtYWluZGVyIHdoZW4gdGhlIG51bWJlciBpcyBkaXZpZGVkIGJ5IDIwMTc/";
        temp="";
        int len = s.size();
        rep1(i,0,len-1)
        {
            temp+=cl(dic[s[i]]);
        }
        len = temp.size();
        //cout << temp<<endl;
        /*
        for (int i = 0;i<=len-2;i+=8)
        {
            int j = i+8-1;
            tot = 0;
            rep1(k,i,j)
            {
                ++tot;
                a[tot] = temp[k]-'0';
            }
            putchar(out());
        }
        这段如果不删掉就能打印出信息
        ->“what is the reminder of x after divided by 2017"
        */
        int T;
        cin >> T;
        while (T--)
        {
            cin >> x;
            cout << x%2017<<endl;
        }
        return 0;
    }
  • 相关阅读:
    5_添加购物车 View+Con
    5_添加购物车 B+M
    5_添加购物车 D
    登录注册V
    bootstrap-标题
    h5整理--详解css的相对定位和绝对定位
    各大门户网站的css初始化代码
    九月二十八JS验证
    js函数和运算符
    4.1原始表达式 9/16
  • 原文地址:https://www.cnblogs.com/AWCXV/p/7626421.html
Copyright © 2011-2022 走看看