第30次CCF计算机软件能力认证——前三题

重复局面

#include <bits/stdc++.h>
#define endl "\n"
#define int long long
using namespace std;
int n; 
map<string,int>mp;
void solve()
{
    cin>>n;
    string s;
    for(int i=1;i<=n;i++)
    {
        s="";
        char c;
        for(int j=1;j<=64;j++)
        {
            cin>>c;
            s+=c;
        }
    //	cout<<s<<endl;
        if(mp[s]>=1)
        {
            mp[s]++;
        }
        else
        {
            mp[s]=1;
        }
        cout<<mp[s]<<endl;
    }
}
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    while (t--)
    {
        solve();
    }
    return 0;
}

矩阵运算 

#include <bits/stdc++.h>
#define endl "\n"
#define int long long
using namespace std;
int n;
int d;
int q[10010][22], k[22][10010], v[10010][22], w[10010];
int ans[10010][22];
int g[22][22];
void solve()
{
    cin >> n >> d;
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= d; j++)
        {
            cin >> q[i][j];
        }
    }
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= d; j++)
        {
            cin >> k[j][i];
        }
    }
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= d; j++)
        {
            cin >> v[i][j];
        }
    }
    for (int i = 1; i <= n; i++)cin >> w[i];
    for (int i = 1; i <= d; i++)
    {
        for (int j = 1; j <= d; j++)
        {
            for (int o = 1; o <= n; o++)
            {
                g[i][j] += k[i][o] * v[o][j];
            }
            //g[i][j] *= w[i];
        }
    }
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= d; j++)
        {
            for (int o = 1; o <= d; o++)
            {
                ans[i][j] += q[i][o] * g[o][j];
            }
            cout << ans[i][j]*w[i] << ' ';
        }
        cout << endl;
    }
}
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    while (t--)
    {
        solve();
    }
    return 0;
}

 解压缩

#include <bits/stdc++.h>
#define endl "\n"
#define int long long
using namespace std;
int n;
int f[10];
string ans;
int cnt;
const int mod = 65539;
void get(int o, int l)
{
    o *= 2;
    while (l--)
    {
        ++cnt;
        ans += ans[cnt - o];
        ++cnt;
        ans += ans[cnt - o];
    }
}
void solve()
{
    cnt = -1;
    cin >> n;//表示输入被解压缩数据的字节数。
    bool flag = 0; //表示是否在引导区
    char c1, c2;
    f[0] = 1;
    for (int i = 1; i <= 5; i++)f[i] = f[i - 1] * 256;
    for (int i = 1; i <= n; i++)
    {
        cin >> c1 >> c2;
        string s = "";
        s += c1;
        s += c2;
        //	cout<<s<<endl;
        string t = bitset<8>(stoi(s, nullptr, 16)).to_string();
        if (flag == 0)
        {
            if (t[0] == '0')
            {
                flag = 1; //引导区结束
            }
            continue;
        }
        //	cout<<t<<endl;
        //数据区
        if (t[6] == '0' && t[7] == '0') //字面量
        {
            int num = stoi(t.substr(0, 6), nullptr, 2);
            if (num > 59)
            {
                int k = num - 59;
                num = 0;
                for (int j = 1; j <= k; j++, i++)
                {
                    cin >> c1 >> c2;
                    string t = "";
                    t += c1;
                    t += c2;
                    num += stoi(t, nullptr, 16) * f[j - 1];
                }
            }
            num++;
            //cout<<"num="<<num<<endl;
            for (int k = 1; k <= num; k++, i++)
            {
                cin >> c1 >> c2;
                cnt += 2;
                ans += c1;
                ans += c2;
            }
        }
        else if (t[6] == '0' && t[7] == '1')//4≤l≤11,0<oo≤2047
        {
            int l = stoi(t.substr(3, 3), nullptr, 2);
            l += 4;
            string o = t.substr(0, 3);
            i++;
            cin >> c1 >> c2;
            s = "";
            s += c1;
            s += c2;
            t = bitset<8>(stoi(s, nullptr, 16)).to_string();
            o = o + t;
            int oo = stoi(o, nullptr, 2);
            //该引用为oo,l
            //	cout<<oo<<' '<<l<<endl;
            get(oo, l);
        }
        else if (t[6] == '1' && t[7] == '0') //1≤l≤64,0<oo≤65535
        {
            int l = stoi(t.substr(0, 6), nullptr, 2);
            l++;
            i++;
            cin >> c1 >> c2;
            s = "";
            s += c1;
            s += c2;
            i++;
            cin >> c1 >> c2;
            s = c2 + s;
            s = c1 + s;
            int oo = stoi(s, nullptr, 16);
            //该引用为oo,l
            get(oo, l);
        }
    }
    for (int i = 0; i < ans.length(); i ++)
    {
        cout << ans[i];
        if ((i + 1) % 16 == 0) cout << endl;
    }
}
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    while (t--)
    {
        solve();
    }
    return 0;
}

  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值