[蓝桥杯 2023 省 A]填空问题1

A. 幸运数

小蓝认为如果一个数含有偶数个数位,并且前面一半的数位之和等于后面一半的数位之和,则这个数是他的幸运数字。例如 23142314 是一个幸运数字,因为它有 44 个数位,并且 2+3=1+42+3=1+4。现在请你帮他计算从 11 至 100000000100000000 之间共有多少个不同的幸运数字。

暴力枚举

代码如下:

#include<bits/stdc++.h>
#define LL_int 128
using namespace std;
const int N = 10000000;
int len;
int n,m;
bool st[N];
int ans=0;
signed main(){
    std::ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    for(int i=1;i<=100000000 ;i++){
        if(i%2==0){
            int a=i/1000;
            int b=i/100%10;
            int c=i%100/10;
            int d=i%10;
            if(a+b==c+d){
                ans++;
            }
        }
    }
    cout<<ans;
    return 0;
}

  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
蓝桥杯2023年B组C++赛的题目包括了2个填空题和8个编程题。根据参赛者的博客\[1\],本届蓝桥杯的难度相较于上届有所增加,编程题的难度较大,而思维题的数量较少。参赛者在博客中提到了其中一个题目,即试题A:日期统计\[2\]。在博客中还提到了一种解题方法,即暴力枚举\[3\]。暴力枚举的代码如下: ```cpp #include <iostream> #include <cmath> #include <algorithm> using namespace std; const int total = 23333333; const double H = 11625907.5798; int main() { for (int i = 0; i < total / 2; i++) { double ans = 0; ans -= 1.0 * i * i / total * log2(1.0 * i / total); ans -= 1.0 * (total - i) * (total - i) / total * log2(1.0 * (total - i) / total); if (abs(ans - H) < 1e-4) { cout << i << endl; return 0; } } return 0; } ``` 以上是关于蓝桥杯2023年B组C++赛的一些信息。希望对你有所帮助! #### 引用[.reference_title] - *1* *3* [2023年第十四届蓝桥杯C++B组复盘](https://blog.csdn.net/m0_46326495/article/details/130043563)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* [2023第十四届蓝桥杯C++B组题目回顾与参赛感想](https://blog.csdn.net/BinBinCome/article/details/130048888)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

drt_0506

你的鼓励将是我创作的最大动力

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

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

打赏作者

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

抵扣说明:

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

余额充值