欢迎加入: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. Python-基础知识汇集

    1.列表 列表是最常用的Python数据类型,它可以作为一个方括号内的逗号分隔值出现. 列表的数据项不需要具有相同的类型 创建一个列表,只要把逗号分隔的不同的数据项使用方括号括起来即可 代码理解:列表 ...

  2. springboot项目上传存储图片到七牛云服务器

    springboot项目上传存储图片到七牛云服务器 问题描述: 当图片存在本地时会出现卡顿的现象.比如一篇图文混排的文章,如果图片没有加载完,可能整个文章都显示不出来,因为它们都是用的同一个服务器. ...

  3. 30m精度土壤类型、土壤质地、土壤有机质、土壤PH、土壤氮磷钾

    ​数据下载链接:数据下载链接 引言 全国土壤类型.质地.养分及变化等信息产品分为土壤类型数据.土壤质地数据.土壤养分数据及土壤变化数据等.该类产品是基于野外调查和实地采样,结合历史数据,建立全国土壤类 ...

  4. springboot中实现权限认证的两个框架

    web开发安全框架 提供认证和授权功能! 一.SpringSecurity 1.导入依赖 <dependency> <groupId>org.springframework.b ...

  5. Maven3 入门到入门

    Maven3 Core Overview Maven是一个项目管理工具,它包含了一个项目对象模型(Project Object Model,POM) ,一组标准集合,一个项目生命周期(Project ...

  6. 我又造了个轮子:GrpcGateway

    我个人对GRPC是比较感兴趣的,最近在玩通过前端调用GRPC.通过前端调用GRPC业界有两种方式:GRPC Web和GRPC JSON转码. GRPC Web 通过JS或者Blazor WASM调用G ...

  7. 6.15 NOI 模拟

    \(T1\ ckr\)与平方数 不会吧,不会吧,真有人不会积分,好吧,我真的一点也不会... 基本公式\(:\) \(1.\)多项式定积分的计算方法 \[f(x)=\sum_{i=0}^nc_ix^i ...

  8. 一文详解 implementation api embed

    最近使用 Android Studio 从事项目开发时,发现对 implementation.api.embed 的用法了解的不是很清楚,这里准备一篇文章对其使用场景或者说是使用方式进行一个总结. d ...

  9. LuoguP2575 高手过招(博弈论)

    空格数变吗?不变呀 阶梯博弈阶梯数变吗?不变呀 那这不就阶梯博弈,每行一栋楼,爬完\(mex\)就可以了吗? #include <iostream> #include <cstdio ...

  10. Luogu5104 红包发红包 (期望)

    曾几何时有人说概率期望easy... 显然,期望是\(\frac{w}{2^n}\) #include <iostream> #include <cstdio> #includ ...