当前位置: 首页 > news >正文

蓝桥杯每日一题2023.10.6

题目描述

门牌制作 - 蓝桥云课 (lanqiao.cn)

题目分析

#include<bits/stdc++.h>
using namespace std;
int ans;
int main()
{for(int i = 1; i <= 2020; i ++){int x = i;while(x){int a = x % 10;if(a == 2)ans ++;x /= 10;}}cout << ans;return 0;
}

题目描述

既约分数 - 蓝桥云课 (lanqiao.cn)

题目分析 

我们由题意暴力枚举

#include<bits/stdc++.h>
using namespace std;
long long ans;
long long gcd(int a, int b)
{return b == 0 ? a : gcd(b, a % b);
}
int main()
{for(int i = 1; i <= 2020; i ++){for(int j = 1; j <= 2020; j ++){if(gcd(i, j) == 1){ans ++;}}}cout << ans;return 0;
}

题目描述

 蛇形填数 - 蓝桥云课 (lanqiao.cn)

 题目分析

 观察图片,我们可以将其分为三大类(r为行,c为列, nextpos代表下一个数的位置

1.第一行

①r = 1, c奇数nextpos(r, c + 1)

②r = 1, c偶数nextpos(r + 1, c - 1)

2.第二行

①c = 1, r偶数nextpos(r + 1, c)

②c = 1,r奇数&&r != 1nextpos(r - 1, c + 1)

3.中间

①r != 1, c != 1, r + c 是奇数(r + 1, c - 1)

②r != 1, c != 1, r + c 是偶数(r - 1, c + 1)

对于这种中间情况举几个例子:
5(2, 2) : 2 + 2 = 4

14(2, 4) : 2 + 4 = 6

13(3, 3) : 3 + 3 = 6

12(4, 2) : 4 + 2 = 6

8(2, 3) : 2 + 3 = 5

9(3, 2) : 3 + 2 = 5

18(3, 4) : 3 + 4 = 7

答案 :761

#include<bits/stdc++.h>
using namespace std;int main()
{int ans = 1;int r = 1, c = 1;while(r != 20 || c != 20){if(r == 1){if(c & 1)c ++;else r ++, c --;}else if(c == 1){if(r % 2 == 0)r ++;else r --, c ++;}else if((r + c) % 2) r ++, c--;else r --, c ++;ans ++;}cout << ans;return 0;
}
http://www.lryc.cn/news/184018.html

相关文章:

  • 7、【Qlib】【主要组件】Data Layer:数据框架与使用
  • Kubernetes安装部署 1
  • 在VS Code中优雅地编辑csv文件
  • LCR 128.库存管理 I
  • eigen::Affine3d 转换
  • 【Python从入门到进阶】38、selenium关于Chrome handless的基本使用
  • 给Python项目创建一个虚拟环境(enev)
  • 【RK3588】YOLO V5在瑞芯微板子上部署问题记录汇总
  • 别人做的百度百科词条信息不全,如何更正自己的百度百科词条
  • [论文精读]U-Net: Convolutional Networks for BiomedicalImage Segmentation
  • Godot Identifier “File“ not declared in the current scope.
  • Java ORM Bee,多表关联更新
  • Java 读取excel文件
  • PageRank(上):数据分析 | 数据挖掘 | 十大算法之一
  • 吃鸡达人专享!提高战斗力,分享干货,查询装备皮肤,保护账号安全!
  • 力扣第101题 c++ 递归 迭代 双方法 +注释 ~
  • Go:实现SMTP邮件发送订阅功能(包含163邮箱、163企业邮箱、谷歌gmail邮箱)
  • Scala第十六章节
  • C语言 实现 链 显示 效果 查找 修改 删除
  • CSS基础语法第一天
  • Leetcode 1492.n的第k个因子
  • 十一工具箱流量主小程序源码
  • 10.5汇编语言整理
  • Connect to 127.0.0.1:1080 [/127.0.0.1] failed: Connection refused: connect
  • 驱动器类产品的接口EMC拓扑方案
  • 2023最新ICP备案查询系统源码 附教程 Thinkphp框架
  • 大数据Doris(六):编译 Doris遇到的问题
  • vue重修004上部
  • 【C++ techniques】要求/禁止/判断—对象产生于堆中
  • 吃鸡高手亲授:玩转绝地求生,分享顶级游戏干货!