欢迎加入: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. RPA应用场景-报税机器人

    场景概述 报税机器人 所涉系统名称 税务网站 人工操作(时间/次) 53分钟 所涉人工数量 60 操作频率 每月 场景流程 1.通过RPA自动将财税信息从对应系统中导出 2.RPA根据不同的税务报表规 ...

  2. 零基础学Python:元组(Tuple)详细教程

    Python的元组与列表类似,不同之处在于元组的元素不能修改,元组使用小括号,列表使用方括号,元组创建很简单,只需要在括号中添加元素,并使用逗号隔开即可https://jq.qq.com/?_wv=1 ...

  3. 论文解读(AGC)《Attributed Graph Clustering via Adaptive Graph Convolution》

    论文信息 论文标题:Attributed Graph Clustering via Adaptive Graph Convolution论文作者:Xiaotong Zhang, Han Liu, Qi ...

  4. Docker安装Portainer管理工具

    1.下载镜像 docker pull portainer/portainer 2.启动 docker run -d -p 9000:9000 --restart=always -v /var/run/ ...

  5. C#.NET笔试题-高级

    1.说说什么是架构模式. 1,分层. 2,分割. 分层是对网站进行横向的切分,那么分割就是对网站进行纵向的切分.将网站按照不同业务分割成小应用,可以有效控制网站的复杂程度. 3,分布式. 在大型网站中 ...

  6. HDFS存储目录分析

    一.介绍 HDFS metadata以树状结构存储整个HDFS上的文件和目录,以及相应的权限.配额和副本因子(replication factor)等.本文基于Hadoop2.6版本介绍HDFS Na ...

  7. Tapdata 数据库实时同步的技术要点

    Tapdata 是由深圳钛铂数据有限公司研发的一款实时数据处理及服务的平台产品,企业可以使用 Tapdata 快速构建数据中台和实时数仓, Tapdata 提供了一站式的解决方案,包括实时数据采集.数 ...

  8. 7.5 The Morning after Halloween

    本题主要是存储的问题,在存储上笔者原先的代码占用了大量的内存空间 这边笔者采用暴力的思想直接硬开所有情况的16^6的数组来存储该问题,当然这在时间上是十分浪费的,因为初始化实在太慢了,剩下的就是状态转 ...

  9. CentOS7添加swap分区

    买了个云主机,只有1G内存,跑爬虫经常内存不足,于是只能添加swap来缓解: 1.官方推荐的swap大小定义 2.使用dd命令在根下创建swapfile dd if=/dev/zero of=/swa ...

  10. 常用的函数式接口_Predicate接口和常用的函数式借楼_Predicate_默认方法and

    package com.yang.Test.PredicateStudy; import java.util.function.Predicate; /** * java.util.function. ...