欢迎加入:qq群号:1054587486

做题链接:https://csp.ccf.org.cn/csp/index.action?_access_code=1584494752035

点击模拟考试进入

1:201912-1

 1 #include <bits/stdc++.h>
2 using namespace std;
3
4 int n;
5
6 bool in(int x){
7 while(x){
8 int t = x % 10;
9 x /= 10;
10 if(t == 7) return true;
11 }
12 return false;
13 }
14
15 int main(){
16 cin >> n;
17 int a = 0, b = 0, c = 0, d = 0;
18 for(int i = 1;i <= n;++i){
19 int t = i / 7;
20 int m = i % 4;
21 bool flag = in(i);
22 if(t * 7 == i || flag){
23 ++n;
24 switch(m){
25 case 0: {++d; break;}
26 case 1: {++a; break;}
27 case 2: {++b; break;}
28 case 3: {++c; break;}
29 default: break;
30 }
31 }
32 }
33 cout << a << endl;
34 cout << b << endl;
35 cout << c << endl;
36 cout << d << endl;
37 return 0;
38 }

2:201912-2

 1 #include <bits/stdc++.h>
2 using namespace std;
3
4 const int N = 1e3+10;
5
6 struct Node{
7 int x, y;
8 Node(int a, int b){
9 x = a, y = b;
10 }
11 };
12 int n;
13
14 struct HashFunc
15 {
16 std::size_t operator()(const Node &key) const
17 {
18 using std::size_t;
19 using std::hash;
20
21 return ((hash<int>()(key.x) ^ (hash<int>()(key.y) << 1)) >> 1);
22 }
23 };
24
25 struct EqualKey
26 {
27 bool operator () (const Node &lhs, const Node &rhs) const
28 {
29 return lhs.x == rhs.x && lhs.y == rhs.y;
30 }
31 };
32
33 int main(){
34 unordered_map<Node, bool, HashFunc, EqualKey> hash;
35 vector<Node> v;
36 cin >> n;
37 for(int i = 0;i < n;++i){
38 int x, y;
39 cin >> x >> y;
40 v.push_back({x, y});
41 hash[v[i]] = true;
42 }
43 int res[5] = {0};
44 for(auto t : v){
45 int x = t.x, y = t.y;
46 if(hash[Node(x-1, y)] && hash[Node(x+1, y)] && hash[Node(x, y+1)] && hash[Node(x, y-1)]){
47 int ans = 0;
48 if(hash[Node(x-1, y-1)]) ++ans;
49 if(hash[Node(x+1, y-1)]) ++ans;
50 if(hash[Node(x-1, y+1)]) ++ans;
51 if(hash[Node(x+1, y+1)]) ++ans;
52 res[ans] ++;
53 }
54 }
55 for(int i = 0;i < 5;++i)cout << res[i] << endl;
56 return 0;
57 }

持续更新中...

csp每日习题的更多相关文章

  1. Python_每日习题-0008-九九乘法表

    题目: 输出9*9乘法口诀表. 程序分析:分行与分列的考虑,共9行9列,i控制行,j控制列. for i in range(1, 10): for j in range(1, i+1): print( ...

  2. Python_每日习题_0007_copy

    题目:将一个列表的数据复制到另一个列表中. 程序分析:使用列表[:],拿不准可以调用copy模块 import copy a = [,,,,['a','b']] b = a #赋值 c = a[:] ...

  3. Python_每日习题_0006_斐波那契数列

    程序设计: 斐波那契数列(Fibonacci sequence),从1,1开始,后面的每一项等于前面两项之和. 图方便就递归实现,图性能就用循环. # for 循环 target = int(inpu ...

  4. Python_每日习题_0005_三数排序

    # 题目: # 输入三个整数x,y,z,请把这三个数由大到小输出. # 程序分析: 练练手就随便找个排序算法实现一下,偷懒就直接调用函数. #方法一:排序 raw = [] for i in rang ...

  5. Python_每日习题_0004_一年中的第几天

    # 题目 输入某年某月某日,判断这一天是这一年的第几天? # 程序分析 特殊情况,闰年时需考虑二月多加一天: def isLeapYear(y): return (y%400==0 or (y%4== ...

  6. Python_每日习题_0003_完全平方数

    # 题目 一个整数,它加上100后是一个完全平方数,再加上168又是一个完全平方数,请问该数是多少? # 程序分析 因为168对于指数爆炸来说实在太小了,所以可以直接省略数学分析,用最朴素的方法来获取 ...

  7. Python_每日习题_0002_个税计算

    # 题目 企业发放的奖金根据利润提成.利润(I)低于或等于10万元时, # 奖金可提10%:利润高于10万元,低于20万元时,低于10万元的部分按10%提成, # 高于10万元的部分,可提成7.%:2 ...

  8. Python_每日习题_0001_数字组合

    # Topic: There are four digits: 1, 2, 3 and 4. # How many different three digits can be formed witho ...

  9. pat乙级每日习题

    欢迎加入我们:qq群:1054587486 1:https://pintia.cn/problem-sets/994805260223102976/problems/99480532591848652 ...

随机推荐

  1. windows系统下.NET CORE c# 通过bat脚本发布iis应用程序,半智能点击式ci/cd

    这里以git为例子讲解: 第一个 pullCode.bat 文件是 拉取代码 git pull 第二个 publish.bat 脚本,编译代码,并发布指定文件夹 dotnet publish &quo ...

  2. 10.2 如何运行Android项目到Android Studio自带模拟器

    Android开发一般都可以将应用运行到模拟器查看效果,除非特殊项目要用到真机,所以我们这里先讲解如何将项目运行到模拟器,以校验我们的开发环境以及创建的项目是否有问题. 创建模拟器 点击"C ...

  3. NC53681 「土」巨石滚滚

    NC53681 「土」巨石滚滚 题目 题目描述 帕秋莉掌握了一种土属性魔法 她使用这种魔法建造了一个大型的土球,并让其一路向下去冲撞障碍 土球有一个稳定性 \(x\) ,如果 \(x < 0\) ...

  4. 动态树 — Euler_Tour_Tree

    一般提到动态树,我们会不约而同的想到 LCT,这算是比较通用,实用,能力较为广泛的一种写法了.当然,掌握 LCT 就需要熟悉掌握 Splay 和各种操作和知识.ETT(中文常用称呼:欧拉游览树)是一种 ...

  5. 一网打尽异步神器CompletableFuture

    最近一直畅游在RocketMQ的源码中,发现在RocketMQ中很多地方都使用到了CompletableFuture,所以今天就跟大家来聊一聊JDK1.8提供的异步神器CompletableFutur ...

  6. SpringMVC pom

    <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://mave ...

  7. 论文阅读 A Data-Driven Graph Generative Model for Temporal Interaction Networks

    13 A Data-Driven Graph Generative Model for Temporal Interaction Networks link:https://scholar.googl ...

  8. 如何验收安卓PCBA主板的质量和性能

    . 版本:v0.1 作者:河东西望 日期:2022-7-15 . 目录 1 有哪些情况需要验收? 2 有哪些验收测试? 2.1 主板测试 2.2 工程测试 2.3 性能测试 2.4 压力测试 2.5 ...

  9. Solution -「HNOI2013」消毒

    弱化一下,先考虑在二维上解决问题. 题目就转化为:有 \(n\) 个点 \((i, j)\) 需要被覆盖,而我们每次可以选一行或一列去覆盖,求覆盖所有点的最少选择次数. 如果我们对于每一个 \((i, ...

  10. 音响音箱/恒温壶/电量显示/电子数字时钟等LED数码管显示驱动IC-VK1640B 8段12位/12段8位显示

    市面上最常用的数码管为七段/八段显示,八段数码管比七段数码管多一个发光二极管单元(比七段数码管多一个点),又按能显示多少个"8"可分为1位.2位.4位等等.数码管又分为共阳极驱动/ ...