CharacterGraph - Intro

semprathlon/CharacterGraph.

 

This Android Project is intended for an Android application to be developed, which enables mutual conversion between a picture and a matrix of characters.

POJ1584-A Round Peg in a Ground Hole - ζёСяêτ - 小優YoU - 博客频道 - CSDN NET

POJ1584-A Round Peg in a Ground Hole - ζёСяêτ - 小優YoU - 博客频道 - CSDN.NET.

转载请注明出处:優YoU  http://user.qzone.qq.com/289065406/blog/1309142308

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
//Memory Time
//268K 0MS

#include<iostream>
#include<cmath>
using namespace std;

const double eps=1e-6;
const double pi=3.141592654;

typedef class NODE
{
public:
double x,y;
}pos;

int n;
double PegR; //钉子半径
pos Peg; //钉子坐标

int precision(double x); //精度讨论
double det(double x1,double y1,double x2,double y2); //叉积
double dotdet(double x1,double y1,double x2,double y2); //点积
double cross(pos A,pos B,pos C,pos D);
double distant(pos A,pos B); //计算距离
double angle(pos A,pos B,pos P); //计算向量PA与PB夹角

bool IsConvexBag(pos* Vectex); //判断输入的点集是否为凸包(本题保证了输入的点集为按某一时针方向有序)
bool IsIn(pos* Vectex); //判断圆心是否在多边形内部
bool IsFit(pos* Vectex); //判断圆的半径是否<=其圆心到多边形所有边的最小距离

int main(void)
{
while(cin>>n && n>=3)
{
cin>>PegR>>Peg.x>>Peg.y;
pos* Vectex=new pos[n+2]; //多边形顶点坐标

for(int i=1;i<=n;i++)
cin>>Vectex[i].x>>Vectex[i].y;

Vectex[0].x=Vectex[n].x; //封闭多边形
Vectex[0].y=Vectex[n].y;
Vectex[n+1].x=Vectex[1].x;
Vectex[n+1].y=Vectex[1].y;

if(!IsConvexBag(Vectex))
cout<<"HOLE IS ILL-FORMED"<<endl;
else
{
bool flag1=IsIn(Vectex);
bool flag2=IsFit(Vectex);

if(flag1 && flag2)
cout<<"PEG WILL FIT"<<endl;
else
cout<<"PEG WILL NOT FIT"<<endl;
}

delete Vectex;
}
return 0;
}

/*精度讨论*/
int precision(double x)
{
if(fabs(x)<=eps)
return 0;
return x>0?1:-1;
}

/*计算点积*/
double dotdet(double x1,double y1,double x2,double y2)
{
return x1*x2+y1*y2;
}

/*计算叉积*/
double det(double x1,double y1,double x2,double y2)
{
return x1*y2-x2*y1;
}
double cross(pos A,pos B,pos C,pos D)
{
return det(B.x-A.x , B.y-A.y , D.x-C.x , D.y-C.y);
}

/*计算距离*/
double distant(pos A,pos B)
{
return sqrt((B.x-A.x)*(B.x-A.x)+(B.y-A.y)*(B.y-A.y));
}

/*计算角度*/
double angle(pos A,pos B,pos P)
{
return acos(dotdet(A.x-P.x,A.y-P.y,B.x-P.x,B.y-P.y)/(distant(A,P)*distant(B,P)));
}

/*凸包判断*/
bool IsConvexBag(pos* Vectex)
{
int direction=0;
//保存点集Vectex的旋转方向direction 1:右手正螺旋,逆时针 -1:左手正螺旋,顺时针
for(int i=0;i<=n-1;i++)
{
int temp=precision(cross(Vectex[i],Vectex[i+1],Vectex[i+1],Vectex[i+2]));

if(!direction) //避免最初的点出现共线的情况
direction=temp;

if(direction*temp<0) //只要Vectex是凸包,那么无论Vectex的旋转方向如何,direction*temp都会>=0
return false;
}
return true;
}

/*判断点与多边形的关系*/
bool IsIn(pos* Vectex)
{
double CircleAngle=0.0; //环绕角
for(int i=1;i<=n;i++) //注意重复边不计算
if(precision(cross(Peg,Vectex[i],Peg,Vectex[i+1]))>=0)
CircleAngle+=angle(Vectex[i],Vectex[i+1],Peg);
else
CircleAngle-=angle(Vectex[i],Vectex[i+1],Peg);

if(precision(CircleAngle)==0) //CircleAngle=0, Peg在多边形外部
return false;
else if(precision(CircleAngle-pi)==0 || precision(CircleAngle+pi)==0) //CircleAngle=180, Peg在多边形边上(不包括顶点)
{
if(precision(PegR)==0)
return true;
}
else if(precision(CircleAngle-2*pi)==0 || precision(CircleAngle+2*pi)==0) //CircleAngle=360, Peg在多边形边内部
return true;
else //CircleAngle=(0,360)之间的任意角, Peg在多边形顶点上
{
if(precision(PegR)==0)
return true;
}
return false;
}

/*判断圆与多边形的关系*/
bool IsFit(pos* Vectex)
{
for(int i=0;i<=n;i++)
{
int k=precision(fabs(cross(Peg,Vectex[i],Peg,Vectex[i+1])/distant(Vectex[i],Vectex[i+1]))-PegR);
if(k<0)
return false;
}

return true;
}

POJ 1556 The Doors(线段交+最短路) - kuangbin - 博客园

POJ 1556 The Doors(线段交+最短路) - kuangbin - 博客园.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
/************************************************************
* Author : kuangbin
* Email : kuangbin2009@126.com
* Last modified : 2013-07-14 10:47
* Filename : POJ1556TheDoors.cpp
* Description :
* *********************************************************/

#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <queue>
#include <map>
#include <vector>
#include <set>
#include <string>
#include <math.h>

using namespace std;

const double eps = 1e-8;
int sgn(double x)
{
if(fabs(x) < eps)return 0;
if(x < 0) return -1;
else return 1;
}
struct Point
{
double x,y;
Point(){}
Point(double _x,double _y)
{
x = _x;y = _y;
}
Point operator -(const Point &b)const
{
return Point(x - b.x,y - b.y);
}
double operator ^(const Point &b)const
{
return x*b.y - y*b.x;
}
double operator *(const Point &b)const
{
return x*b.x + y*b.y;
}
};
struct Line
{
Point s,e;
Line(){}
Line(Point _s,Point _e)
{
s = _s;e = _e;
}
};
//判断线段相交
bool inter(Line l1,Line l2)
{
return
max(l1.s.x,l1.e.x) >= min(l2.s.x,l2.e.x) &&
max(l2.s.x,l2.e.x) >= min(l1.s.x,l1.e.x) &&
max(l1.s.y,l1.e.y) >= min(l2.s.y,l2.e.y) &&
max(l2.s.y,l2.e.y) >= min(l1.s.y,l1.e.y) &&
sgn((l2.s-l1.s)^(l1.e-l1.s))*sgn((l2.e-l1.s)^(l1.e-l1.s)) <= 0 &&
sgn((l1.s-l2.s)^(l2.e-l2.s))*sgn((l1.e-l2.s)^(l2.e-l2.s)) <= 0;
}
double dist(Point a,Point b)
{
return sqrt((b-a)*(b-a));
}
const int MAXN = 100;
Line line[MAXN];
double dis[MAXN][MAXN];
const double INF = 1e20;
int main()
{
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
int n;
double x,y1,y2,y3,y4;
while(scanf("%d",&n) == 1)
{
if(n == -1) break;
for(int i = 1;i <= n;i++)
{
scanf("%lf%lf%lf%lf%lf",&x,&y1,&y2,&y3,&y4);
line[2*i-1] = Line(Point(x,y1),Point(x,y2));
line[2*i] = Line(Point(x,y3),Point(x,y4));
}
for(int i = 0;i <= 4*n+1;i++)
for(int j = 0;j <= 4*n+1;j++)
{
if(i == j)dis[i][j] = 0;
else dis[i][j] = INF;
}
for(int i = 1;i <= 4*n;i++)
{
int lid = (i+3)/4;
bool flag = true;
Point tmp;
if(i&1)tmp = line[(i+1)/2].s;
else tmp = line[(i+1)/2].e;
for(int j = 1;j < lid;j++)
if(inter(line[2*j-1],Line(Point(0,5),tmp)) == false
&& inter(line[2*j],Line(Point(0,5),tmp)) == false)
flag = false;
if(flag)dis[0][i] =dis[i][0] = dist(Point(0,5),tmp);
flag = true;
for(int j = lid+1;j <= n;j++)
if(inter(line[2*j-1],Line(Point(10,5),tmp)) == false
&& inter(line[2*j],Line(Point(10,5),tmp)) == false)
flag = false;
if(flag)dis[i][4*n+1] =dis[4*n+1][i] = dist(Point(10,5),tmp);
}
for(int i = 1;i <= 4*n;i++)
for(int j = i+1;j <=4*n;j++)
{
int lid1 = (i+3)/4;
int lid2 = (j+3)/4;
bool flag = true;
Point p1,p2;
if(i&1)p1 = line[(i+1)/2].s;
else p1 = line[(i+1)/2].e;
if(j&1)p2 = line[(j+1)/2].s;
else p2 = line[(j+1)/2].e;
for(int k = lid1+1;k < lid2;k++)
if(inter(line[2*k-1],Line(p1,p2)) == false
&& inter(line[2*k],Line(p1,p2)) == false)
flag = false;
if(flag) dis[i][j] = dis[j][i] = dist(p1,p2);
}
bool flag = true;
for(int i = 1;i <= n;i++)
if(inter(line[2*i-1],Line(Point(0,5),Point(10,5))) == false
&& inter(line[2*i],Line(Point(0,5),Point(10,5))) == false)
flag = false;
if(flag)dis[0][4*n+1] = dis[4*n+1][0] = 10;
for(int k = 0;k <= 4*n+1;k++)
for(int i = 0;i <= 4*n+1;i++)
for(int j = 0;j <= 4*n+1;j++)
if(dis[i][k] + dis[k][j] < dis[i][j])
dis[i][j] = dis[i][k] + dis[k][j];
printf("%.2lf\n",dis[0][4*n+1]);
}

return 0;
}

My Git Note

Note! 益rz


Unix的哲学是“没有消息就是好消息”

基本操作

-新增文件:git add {readme.txt}

-提交并注释:git commit -m “{wrote a readme file}”

-仓库初始化:git init

-取得仓库状态:git status

分支管理

参考指针或链表模型

-新建分支并切换:git checkout [-b] {dev}

-查看分支:git branch

-切换分支:git checkout [master]

-合并分支:git merge

-删除分支:git branch -d

使用github+jekyll搭建blog环境,完美替代wordpress-前端随记

使用github+jekyll搭建blog环境,完美替代wordpress-前端随记-黑妞哈哈.

也来讲讲怎么使用github pages做blog环境

优点

空间免费,github托管,稳定又安全,遭遇过空间商跑路的朋友是不是想起伤心往事;

允许本地服务器调试,脱离网络写文章毫无压力,因为可以使用git命令同步来管理文章,版本控制妥妥的,对技术人员来说,一键恢复,实在是神物;

还能绑定顶级域名,亲,人家免费空间竟然还允许我们绑域名有木有~~;

文章用markedown编写,以前遭受排版困扰的亲们是不是很激动;

购买域名

(略)

用免费的dnsPod做域名解析

dnspod链接地址https://www.dnspod.cn/ dnspod settings

github注册和本地电脑jekyll等环境配置

参考最底下的参考文章,省略。。。

命令

  1. git命令获取远程文件

    git clone git@github.com:heiniuhaha/heiniuhaha.github.com.git
  2. 定位到目录heiniu.github.com

    cd .ssh/heiniuhaha.github.com
  3. 使用rake命令

    rake page           # Create a new page.
    rake post           # Begin a new post in ./_posts
    rake preview        # Launch preview environment
  4. 写文章的时候学习下markdown语法

    如:中文单引号 ` 用来标注小块代码,如github jekyll

  5. 最后提交git代码

    git add .
    git commit . -m 'just another commit'

日常发布完整命令

git clone git@github.com:heiniuhaha/heiniuhaha.github.com.git//本地如果无远程代码,先做这步,不然就忽略
cd .ssh/heiniuhaha.github.com//定位到你blog的目录下
git pull origin master //先同步远程文件,后面的参数会自动连接你远程的文件
git status //查看本地自己修改了多少文件
git add .//添加远程不存在的git文件
git commit * -m "what I want told to someone"
git push origin master //更新到远程服务器上

参考文章

附件:git api 总结图

git-api

Guide

Pixiv推荐