欢迎加入: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 }

持续更新中...

最新文章

  1. NOIp2016 十连测 round1
  2. Java EE-Eclipse 运行Jsp项目遇到的几个问题及解决方法
  3. 如果客户端禁用cookie,session还能使用吗?
  4. Grpc微服务从零入门
  5. 【翻译四】java-并发之线程暂停
  6. NDK开发总结
  7. RunTime(运行时机制)
  8. 如何用adb logcat保存日志
  9. HDU 3065 (AC自动机模板题)
  10. mysql学习笔记5
  11. 关于ASP.NET控件方面的学习(恢复版)
  12. DBCONN
  13. [LeetCode]题解(python):066-Plus One
  14. Java中关键词之this,super的使用
  15. R语言实现SOM(自组织映射)模型(三个函数包+代码)
  16. git温习
  17. 面试简单整理之zookeeper
  18. Windows Server 2008 R2终端服务器激活方法
  19. Cpp读文件、CString转String、String转CString
  20. 闲聊jQuery(一)

热门文章

  1. idea显示 RunDashboard ,多个启动项时列表显示
  2. Microsoft Office Visio Professional 之用例图
  3. java运算符(超详细!!!)
  4. DTCC 干货分享:Real Time DaaS - 面向TP+AP业务的数据平台架构
  5. 如何等待ajax完成再执行相应操作
  6. 【docker专栏6】详解docker容器状态转换管理命令
  7. java的类
  8. -bash: nignx: 未找到命令
  9. 第十三天python3 生成器yield
  10. netcore 非注入全局获取配置文件