UVALive 6602 Counting Lattice Squares】的更多相关文章

题意:给定一个n*m的矩阵,问你里面有几面积为奇数的正方形. 析:首先能知道的是,大的矩阵是包括小的矩阵的,而且面积为奇数,我们只要考虑恰好在边界上的正方形即可,画几个看看就知道了,如果是3*3的有3个, 5*5有5个,偶数没有,因为面积为奇数.那么结果就有了. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #in…
给定一个n*m的网格,求面积为奇数的正方形有多少个. 首先是n*m个面积为1的,然后剩下的要么是边长为奇数,要么被这样一个奇数边长所包围. 原因如下: 对于一个边长不平行于坐标抽的正方形,其边长一定是某个长方形的对角线,而且长方形长宽a,b一定是一奇数,一偶数,这样area = a^2+b^2才是奇数. 所以可以对任何奇数i <= min(n, m) 求出这样的边长正方形以及被包围的正方形个数. 注意对于一个奇数例如5,被包围的正方形可以是以1和4的对角线,2和3的对角线为边,这样对任何一个奇数…
B - Counting BST Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu Submit Status Practice UVALive 5058 Description Binary Search Tree (BST) is a rooted binary tree data structure which has following properties: Left subtree conta…
题意:排序二叉树按照数插入的顺序不同会出现不同的结构,现在要在1~m选n个数,使按顺序插入形成的结构与给出的结构相同,有多少种选法. 解法:先将给出的结构插入,构造出一棵排序二叉树,再dfs统计,首先赋ans = C(m,n),从m个数中取n个数,然后将这n个数安排插入顺序,dfs,如果此时节点左右子树都有,那么其实左右子树的插入顺序可以相间,所有就是一个排列保持相对顺序不变地插入另一个保持相对顺序不变的序列中,有多少种插入方法呢,如果一个序列个数为k1,另一个为k2,那么方法数为:C(k1+k…
题目链接:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1296 题意:给出一个a*b的网格,在网格上取不共线的三点构成三角形,求三角形总数.分析:就是一一道简单的组合数计算题目,设总结点数为n,则取三个节点的个数为C(n,3), 然后减去横向.竖向.斜向的三点共线的个数即可,斜线三点共线等价于所枚举的矩形的长宽成倍数关系,…
就欧拉函数然后地推一下. #include <map> #include <set> #include <list> #include <cmath> #include <ctime> #include <deque> #include <stack> #include <queue> #include <cctype> #include <cstdio> #include <st…
题目链接:点击打开链接 #include <cstdio> #include <vector> using namespace std; typedef long long ll; ll re; vector<int> p; void dfs(int dep, int g) { if (dep == 0) return ; if (p[dep-1] == 1) { re += (dep-1) * (1ll<< (dep-2)); re += g * (1ll…
第一次的增补赛,也是第一场个人排位赛,讲道理打的和屎一样,手速题卡了好久还WA了好多发,难题又切不出来,这种情况是最尴尬的吧! Individual Contest #1: Ploblem D: 题意:给你一个含有N个元素的数组和操作次数m,然后求出经过m次操作后,从区间X到Y的总和:操作如下:{1,6,9}==>{1,7,6,15,9}(多CASE) 题目链接:https://www.codechef.com/problems/CHSPARR 思路: 首先,最容易想到的是单纯的模拟每一次这样的…
题目描述 Sylvester Stallion is an old horse who likes nothing better than to wander around in the fields around his stable. Sylvester is a little single minded and will walk in a straight line unless there is a rock in this path. If that\'s the case, he…
A: UVALive 6525 cid=61196#problem/A" style="color:blue; text-decoration:none">Attacking rooks 题解:点击打开链接 C: UVALive 6527 Counting ones 题解:点击打开链接 E: UVALive 6529 Eleven 题解:点击打开链接 F: UVALive 6530 Football 题解:点击打开链接 G: option=com_onlinejudge…
Counting Squares Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 1885    Accepted Submission(s): 946 Problem Description Your input is a series of rectangles, one per line. Each rectangle is sp…
Counting Squares Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 1072    Accepted Submission(s): 529 Problem DescriptionYour input is a series of rectangles, one per line. Each rectangle is spec…
版权声明:欢迎关注我的博客.本文为博主[炒饭君]原创文章,未经博主同意不得转载 https://blog.csdn.net/a1061747415/article/details/25471349 Problem A : Counting Squares pid=1264" rel="nofollow">From:HDU, 1264 Problem Description Your input is a series of rectangles, one per lin…
题目链接:UVALive 4025 Color Squares 按题意要求放带有颜色的块,求达到w分的最少步数. //yy:哇,看别人存下整个棋盘的状态来做,我什么都不想说了,不知道下午自己写了些什么东西,训练结束补的.. #include <cstdio> #include <cstring> #include <algorithm> #include <queue> #define CLR(a, b) memset((a),(b),sizeof((a))…
题目链接 Problem Description Your input is a series of rectangles, one per line. Each rectangle is specified as two points(X,Y) that specify the opposite corners of a rectangle. All coordinates will be integers in the range 0 to 100. For example, the lin…
Squares The famous Korean IT company  plans to make a digital map of the Earth with help of wireless sensors which spread out in rough terrains. Each sensor sends a geographical data to . But, due to the inaccuracy of the sensing devices equipped in…
Your input is a series of rectangles, one per line. Each rectangle is specified as two points(X,Y) that specify the opposite corners of a rectangle. All coordinates will be integers in the range 0 to 100. For example, the line 5 8 7 10 specifies the…
题意:n个平行于坐标轴的正方形,求出最远点对的平方 题解:首先求出凸包,可以证明最远点对一定是凸包上的点对,接着可以证明最远点对(每个点的对踵点)一定只有3*n/2对 接着使用旋转卡壳找到最远点对,但是白书上的算法过于麻烦 所以我看到一个简单想法就是: 可以直接枚举每个点,接着枚举这个点对应最远的点(三角形面积最大) 这儿对踵点满足一个单峰性质,所以可以使用类似双指针方式维护 //n个平行于坐标轴的正方形,求出最远点对的平方 #include<cstdio> #include<cstri…
题目链接: 题目链接 题意:如果一个数二进制n有k位1,那么f1[n] = k,如果k有s位二进制1,那么f2[n] = f1[k] = s.  如此往复,直到fx[n] = 1,此时的x就是n的”K值“,现在要求[L,R]内的”K值“为X的数有多少个.(1<=L<=R<=10^18) 解法:首先可以看到10^18最多只有61位左右的数,所以我们只需处理1~61之间每个数有多少个1,即可知道1~61之间每个数”K值“是多少. 然后就将求[L,R]之间的个数变成求[1,R]-[1,L-1]…
题意:求所有正方形中两点距离最大值的平方值. 思路:旋转卡壳法. 分别用数组和vector存凸包时,旋转卡壳代码有所不同. #include<cstdio> #include<cmath> #include<cstring> #include<algorithm> #include<iostream> #include<memory.h> #include<cstdlib> #include<vector> #…
来之不易的2017第一发ac http://poj.org/problem?id=2386 Lake Counting Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 31474   Accepted: 15724 Description Due to recent rains, water has pooled in various places in Farmer John's field, which is repr…
Lake Counting Time Limit: 1000MS     Memory Limit: 65536K Total Submissions: 17917     Accepted: 9069 Description Due to recent rains, water has pooled in various places in Farmer John's field, which is represented by a rectangle of N x M (1 <= N <=…
Lake Counting Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 28966   Accepted: 14505 Description Due to recent rains, water has pooled in various places in Farmer John's field, which is represented by a rectangle of N x M (1 <= N <= 10…
Counting Squares Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 1086    Accepted Submission(s): 540 Problem Description Your input is a series of rectangles, one per line. Each rectangle is sp…
 Squares  A children's board game consists of a square array of dots that contains lines connecting some of the pairs of adjacent dots. One part of the game requires that the players count the number of squares of certain sizes that are formed by the…
1751: [Usaco2005 qua]Lake Counting Time Limit: 5 Sec  Memory Limit: 64 MB Submit: 168  Solved: 130 [Submit][Status] Description Due to recent rains, water has pooled in various places in Farmer John's field, which is represented by a rectangle of N x…
1751: [Usaco2005 qua]Lake Counting Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 190  Solved: 150[Submit][Status][Discuss] Description Due to recent rains, water has pooled in various places in Farmer John's field, which is represented by a rectangle…
题目链接 https://www.luogu.org/problemnew/show/P1596 题目描述 Due to recent rains, water has pooled in various places in Farmer John's field, which is represented by a rectangle of N x M (1 <= N <= 100; 1 <= M <= 100) squares. Each square contains eit…
Lake Counting Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 49414   Accepted: 24273 Description Due to recent rains, water has pooled in various places in Farmer John's field, which is represented by a rectangle of N x M (1 <= N <= 10…
Lake Counting Description Due to recent rains, water has pooled in various places in Farmer John's field, which is represented by a rectangle of N x M (1 <= N <= 100; 1 <= M <= 100) squares. Each square contains either water ('W') or dry land…