CCF认证真题-(201409-2)-画图(暴力)

 1 #include <iostream>
 2 #include <algorithm>
 3 #include <set>
 4 using namespace std;
 5
 6 bool vis[105][105]{false};
 7 int main()
 8 {
 9     ios::sync_with_stdio(false);
10     cin.tie(0);
11     int n;
12     cin >> n;
13     int x1, y1, x2, y2, s = 0;
14     for (int i = 1; i <= n; i++) {
15         cin >> x1 >> y1 >> x2 >> y2;
16         for (int x = x1; x < x2; x++) {
17             for (int y = y1; y < y2; y++) {
18                 if (!vis[x][y]) {
19                     s++;
20                     vis[x][y] = true;
21                 }
22             }
23         }
24     }
25     cout << s << endl;
26     return 0;
27 }

原文地址:https://www.cnblogs.com/AntonLiu/p/11163726.html

时间: 2024-08-28 07:47:57

CCF认证真题-(201409-2)-画图(暴力)的相关文章

CCF认证真题-(201312-1)-出现次数最多的数

1 #include <iostream> 2 using namespace std; 3 int arr[10005]; 4 int main() 5 { 6 ios::sync_with_stdio(false); 7 cin.tie(0); 8 int n; 9 cin >> n; 10 int x, maxn = 0; 11 for (int i = 0; i < n; i++) { 12 cin >> x; 13 maxn = x > maxn

CCF认证真题-(201312-2)-ISBN号码(模拟)

#include <iostream> #include <algorithm> using namespace std; int arr[10005]; int toNum(char ch) {return ch - '0';} int main() { ios::sync_with_stdio(false); cin.tie(0); string s; cin >> s; int num = toNum(s[0]) + toNum(s[2]) * 2 + toNum

CCF认证真题-(201412-2)-Z字形扫描

1 #include <iostream> 2 using namespace std; 3 int arr[505][505]; 4 bool flag; 5 int n; 6 void printComp(int x1, int y1, int x2, int y2) 7 { 8 int i = x1, j = y1; 9 if (x1 == n && x2 == n) { 10 cout << arr[n][n] << endl; 11 retur

CCF认证真题-(201509-2)-日期计算

1 #include <iostream> 2 using namespace std; 3 int month[2][13] {{0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}, 4 {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}}; 5 6 bool isLeap(int y) 7 { 8 return y % 400 == 0 || (y % 4 == 0 &&

CCF认证真题-(201509-1)-数列分段

1 #include <iostream> 2 using namespace std; 3 int main() 4 { 5 ios::sync_with_stdio(false); 6 cin.tie(0); 7 8 int n; 9 cin >> n; 10 int pre; 11 cin >> pre; 12 int ans = 1; 13 for (int i = 1; i < n; i++) { 14 int x; 15 cin >> x;

CCF考试真题题解

CCF考试认证:题解参考博客http://blog.csdn.net/u014578266/article/details/45221841 问题描述 试题编号: 201503-1 试题名称: 图像旋转 时间限制: 5.0s 内存限制: 256.0MB 问题描述: 问题描述 旋转是图像处理的基本操作,在这个问题中,你需要将一个图像逆时针旋转90度. 计算机中的图像表示可以用一个矩阵来表示,为了旋转一个图像,只需要将对应的矩阵旋转即可. 输入格式 输入的第一行包含两个整数n, m,分别表示图像矩阵

ccf历年真题(截至2015年9月)

问题描述 试题编号: 201509-1 试题名称: 数列分段 时间限制: 1.0s 内存限制: 256.0MB 问题描述: 问题描述 给定一个整数数列,数列中连续相同的最长整数序列算成一段,问数列中共有多少段? 输入格式 输入的第一行包含一个整数n,表示数列中整数的个数. 第二行包含n个整数a1, a2, …, an,表示给定的数列,相邻的整数之间用一个空格分隔. 输出格式 输出一个整数,表示给定的数列有多个段. 样例输入 8 8 8 8 0 12 12 8 0 样例输出 5 样例说明 8 8

ccf认证模拟题之三---最大的矩形

问题描述 在横轴上放了n个相邻的矩形,每个矩形的宽度是1,而第i(1 ≤ i ≤ n)个矩形的高度是hi.这n个矩形构成了一个直方图.例如,下图中六个矩形的高度就分别是3, 1, 6, 5, 2, 3. 请找出能放在给定直方图里面积最大的矩形,它的边要与坐标轴平行.对于上面给出的例子,最大矩形如下图所示的阴影部分,面积是10. 输入格式 第一行包含一个整数n,即矩形的数量(1 ≤ n ≤ 1000). 第二行包含n 个整数h1, h2, … , hn,相邻的数之间由空格分隔.(1 ≤ hi ≤

给定n个不同的整数,问这些数中有多少对整数,它们的值正好相差1(ccf真题)

ccf认证考试2014年9月第一题 问题描述 给定n个不同的整数,问这些数中有多少对整数,它们的值正好相差1. 输入格式 输入的第一行包含一个整数n,表示给定整数的个数. 第二行包含所给定的n个整数. 输出格式 输出一个整数,表示值正好相差1的数对的个数. 样例输入 6 10 2 6 3 7 8 样例输出 3 样例说明 值正好相差1的数对包括(2, 3), (6, 7), (7, 8). 评测用例规模与约定 1<=n<=1000,给定的整数为不超过10000的非负整数. #include<