蓝桥2013年省赛A组题目题解

填空题

高斯日记

在这里插入图片描述
正确答案:

1799-7-16
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int months[13] = {
   
   0,31,0,31,30,31,30,31,31,30,31,30,31};
bool check(int x)
{
   
   
    if((x%4 == 0 && x%100) || x%400 == 0) return true;
    return false;
}
int main()
{
   
   
    int tot = 8113, cnt = 0;

    int year = 1777,  m = 4, d = 30;

    while(cnt  != tot)
    {
   
   
        if(check(year)) months[2] = 29;
        else months[2] = 28;

        for(int i = m; i <= 12; i++,m++)
        {
   
   
            for(int j = d; j <= months[i]; j++,d++)
            {
   
   
                cnt++;
                if(j== months[i]) d = 0;
                if(cnt == tot) break;
            }
            if(i == 12) m = 0;
            if(cnt == tot) break;
        }
        if(cnt != tot) year++;
    }
    printf("%d-%d-%d\n",year,m,d);
    return 0;
}

排它平方数

在这里插入图片描述
正确答案:

639172
#include <iostream>
#include <cstdio>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
set<int> work(ll x)
{
   
   
    set<int>c;
    while(x)
    {
   
   
        c.insert(x%10);
        x /= 10;
    }
    return c;
}
int main()
{
   
   
    set<int> a, b;
    vector<int>v;
    for(int i =100000; i <= 999999; i++)
    {
   
   
        a.clear(); b.clear();
        int t = i;
        a = work(t);
        if(a.size() != 6) continue;
        ll ans = i;
        ans = ans*ans;
        b = work(ans);
        int ok = 1;
        for(set<int>::iterator it = b.begin(); it != b.end(); it++)
            if(a.find(*it) != a.end()) ok = 0;
        if(ok) v.push_back(i);
    }
    for(auto s : v) cout<<s<<'\n';
    return 0;
}

振兴中华

在这里插入图片描述
正确答案:

35
#include <algorithm>
using namespace std;
typedef long long ll;
int dp[6][6];
int main()
{
   
   
    dp[1][1] = 1;
    for(int i = 1; i <= 4; i++)
        for(int j = 1; j <= 5; j++)
            dp[i][j] += dp[i-1][j]+dp[i][j-1];
    cout<<dp[4][5]<<endl;
    return 0;
}

颠倒的价值

在这里插入图片描述
正确答案:

9088
#include <iostream>
#include <cstdio>
#include <string>
#include <set>
#include <unordered_map>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
unordered_map<int,int>mp;
struct node{
   
   
    int ago, now;
};
void init()
{
   
   
    for(int i = 0; i < 10; i++)
    {
   
   
        if(i == 6) mp[6] = 9;
        else if(i == 9) mp[9] = 6;
        else mp[i] = i;
    }
}
int main()
{
   
   
    init();
    vector<node> a, b;
    for(int i = 1000; i <= 9999; i++)
    {
   
   
        int t = i;
        string temp = "";
        while(t)
        {
   
   
            temp += (char)(mp[t%10] + '0');
            t /= 10;
        }
        if(temp[0] == '0') continue;
        int y = 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

幸愉信奥

谢谢亲的支持,我会继续努力啦~

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值