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