C# arcengine 获取一条线上的点
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了C# arcengine 获取一条线上的点相关的知识,希望对你有一定的参考价值。
现在有很多线段都是由三个点组成,第一点和第二点组成的线是用来求长度的,第二点和第三点组成的线是需要与道路线相交的,现在需要获得第一点和第二点求长度,我应该如何获取这两个点,有方法或是别的什么的嘛?很着急,求大神、高手帮组,在线等,所有积分跪求!
参考技术A (IPolygon as IPointCollection) .GetPoint(int i);本回答被提问者采纳[LintCode] Coins in a Line 一条线上的硬币
There are n coins in a line. Two players take turns to take one or two coins from right side until there are no more coins left. The player who take the last coin wins.
Could you please decide the first play will win or lose?
Example
n = 1
, return true
.
n = 2
, return true
.
n = 3
, return false
.
n = 4
, return true
.
n = 5
, return true
.
Challenge
O(n) time and O(1) memory
跟LeetCode上的那道Nim Game几乎一模一样。
解法一:
class Solution { public: /** * @param n: an integer * @return: a boolean which equals to true if the first player will win */ bool firstWillWin(int n) { if (n <= 0) return false; if (n <= 2) return true; vector<bool> dp(n + 1, true); dp[3] = false; for (int i = 4; i <= n; ++i) { dp[i] = dp[i - 3]; } return dp.back(); } };
解法二:
class Solution { public: /** * @param n: an integer * @return: a boolean which equals to true if the first player will win */ bool firstWillWin(int n) { return n % 3 != 0; } };
以上是关于C# arcengine 获取一条线上的点的主要内容,如果未能解决你的问题,请参考以下文章
Educational Codeforces Round 41
Educational Codeforces Round 41(已补D,E)