不知 是怎么看出的精度不够,吸经验吧。#include #include #include #include #include using namespace std;char str[1000050];int dir[10][2]={{0,0},{-1,-1},{0,-1},{1,-1},{-1,...
转载 2014-07-28 20:50:00
8阅读
2评论
题意:从原点出发,沿着8个方向走,每次走1个点格或者根号2个点格的距离,最终回到原点,求围住的多边形面积。分析:直接记录所经过的点,然后计算多边形面积。注意,不用先保存所有的点,然后计算面积,边走变算,不然会超内存。最多有1000000个点。注意:精度问题,使用long long /__int64,直接使用double不准确。方向的处理使用数组。// Time 94ms; Memory 1036K #include #include #define maxn 1000010 using namespace std; char s[maxn]; long long dx[]={-1,0,1,..
转载 2013-07-25 08:16:00
21阅读
2评论
#include<iostream> //多边形面积#include<string>using namespace std;struct point{ int x,y;}p[1000010];int move[10][2]={{},{-1,-1},{0,-1},{1,-1},{-1,0},{},{1,0},{-1,1},{0,1},{1,1}};int main(){ int cases; string str; cin>>cases; while(cases--) { cin>>str; int n=str.size()-1; if(n<
转载 2011-07-22 22:46:00
45阅读
数论 叉积
原创 2023-02-23 10:02:10
28阅读
给出八方向行走方案求路线圈出的面积。计算面积时总是算二倍的面积,这样就可以处理0.5的问题。View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>using namespace std;int main(){ //freopen("t.txt", "r", stdin); int t; scanf("%d", &t); getc
转载 2011-06-15 21:07:00
41阅读
2评论
这道题一咋看好简单,就是多边形求面积嘛,但是Wrong了很多次,看看discuss才知道用double有精度问题要用long long 或__int64,这就不明白了.不过换成long long之后就过了。不过有的人在纠结开数组的问题,这个问题不是问题。贴贴代码把:#include<iostream> #include<cmath> using namespace std; int d[10][2]={{0,0}, {-1,-1},{0,-1},{1,-1},{-1,0},{0,0},{1,0},{-1,1},{0,1},{1,1}};//方向 char str[100
转载 2012-07-15 21:35:00
60阅读
2评论
题意:从原点出发,沿着8个方向走,每次走1个点格或者根号2个点格的距离,最终回到原点,求围住的多边形面积。 分析:直接记录所经过的点,然后计算多边形面积。注意,不用先保存所有的点,然后计算面积,边走变算,不然会超内存。最多有1000000个点。 注意:精度问题,使用long long /__int64,直接使用double不准确。方向的处理使用数组。 // Time 94ms; Memory 1036K#include#include#define maxn 1000010using namespace std;char s[maxn];long long dx[]=...
转载 2013-07-25 19:22:00
57阅读
2评论
P1654 OSU! 链接 有:\((x+1)^3=x^3+3x^2+3x+1\) 注意,\(len\) 有两种改变方式:\(0\) 或 \(len+1\) ,\(ans_1\) 有两种改变方式:\(ans_1+2\times len+1\) 或 \(0\) 。 而 \(ans_2\) 也有两种:\ ...
转载 2021-07-12 14:43:00
36阅读
2评论
题意: 从一个点出发,8个方向,给出每一步的方向,求出走过的路径形成的多边形的面积。 思路: 先普及一下向量叉乘、、 (摘自度娘) 也就是x1y2-x2y1。 那这不就好说了嘛。 一个经过原点的闭合多边形的面积可以分割成多个三角形。 每个三角形的面积就是相邻向量叉乘的一半。 大功...
转载 2016-07-11 20:35:00
52阅读
2评论
P1654 OSU! 题目 题目背景 原 《产品排序》 参见P2577 题目描述 osu 是一款群众喜闻乐见的休闲软件。 我们可以把osu的规则简化与改编成以下的样子: 一共有n次操作,每次操作只有成功与失败之分,成功对应1,失败对应0,n次操作对应为1个长度为n的01串。在这个串中连续的 \(X\ ...
转载 2021-10-15 22:14:00
19阅读
2评论
这个题就是求一个封闭区间内的面积。要先知道的:两个相邻向量(x1,y1)和(x2,y2)之间的平行四边形的面积为: abs(x1*y2-x2*y1)把所有两邻边的总面积算出来相加就行。#include#include#include#include#include#include#include#include#include#include
原创 2023-07-27 18:45:54
48阅读
有一个长度为$n$的序列,其中第$i$个位置有$a_i$的概率为$1$。问所有极长的连续的$1$的长度立方和的期望。
转载 2020-10-28 12:45:00
63阅读
Zoj1654 标准解法:二分匈牙利。 写法各异嘛,看不懂或者懒得看也正常,如果想了解我思路的可以和我讨论的。 在练习sap,所以还是写了一遍:
转载 2017-09-27 21:06:00
76阅读
2评论
#include#include#include#includeusing namespace std;int dx[10]={0,1,1,1,0,0,0,-1,-1,-1};int dy[10]={0,-1,0,1,-1,0,1,-1,0,1};char s[1000010];__int64 ar...
IT
原创 2021-07-16 14:59:03
46阅读
题目传送门 先设 \(x\) 为当前得分,当又得到 \(1\) 分时,有: \[ (x+1)^3=x^3+3x^2+3x+1 \] 由于原先得分为 \(x^3\) ,可知每次 \(+1\) 都会增加 \(3x^2+3x+1\) 分。 在代码实现过程中,用 \(x\) 维护一维 \(x\) ,\(y\ ...
转载 2021-07-15 21:24:00
95阅读
2评论
[题解] P1654 OSU! 传送门 解题报告 题意描述自己看吧。 考虑到两个公式: \((a+b)^2=a^2+2ab+b^2\) \((a+b)^3=a^3+3a^2b+3ab^2+b^3\) 不妨设 DP 数组 \(f[i][0/1]\) 表示第 \(1\) 到 \(i\) 位 \(1\) ...
转载 2021-08-12 18:20:00
78阅读
2评论
AreaTime Limit:1000MSMemory Limit:10000KTotal Submissions:9899Accepted:2800DescriptionYou are going to compute the area of a special kind of polygon. One vertex of the polygon is the origin of the orthogonal coordinate system. From this vertex, you may go step by step to the following vertexes of th
转载 2012-04-19 19:55:00
63阅读
2评论
1654. Cipher MessageTime limit: 1.0 secondMemory limit: 64 MBMüller tried to catch Stierlitz red-handed many times, but always failed because Stierlitz could ever find some excuse. Once
原创 2023-04-12 05:28:03
62阅读
洛谷 P1654 OSU! 洛谷传送门 题目背景 原 《产品排序》 参见P2577 题目描述 osu 是一款群众喜闻乐见的休闲软件。 我们可以把osu的规则简化与改编成以下的样子: 一共有n次操作,每次操作只有成功与失败之分,成功对应1,失败对应0,n次操作对应为1个长度为n的01串。在这个串中连续
转载 2020-10-20 08:19:00
80阅读
2评论
Robert is a famous engineer. One day he was given a task by hi
转载 2017-05-22 13:14:00
25阅读
  • 1
  • 2
  • 3
  • 4
  • 5