频道栏目
首页 > 资讯 > 其他 > 正文

Shape Number HDU - 4162(最小表示法)

17-09-04        来源:[db:作者]  
收藏   我要投稿

In computer vision, a chain code is a sequence of numbers representing directions when following the contour of an object. For example, the following figure shows the contour represented by the chain code 22234446466001207560 (starting at the upper-left corner).

Two chain codes may represent the same shape if the shape has been rotated, or if a different starting point is chosen for the contour. To normalize the code for rotation, we can compute the first difference of the chain code instead. The first difference is obtained by counting the number of direction changes in counterclockwise direction between consecutive elements in the chain code (the last element is consecutive with the first one). In the above code, the first difference is

00110026202011676122
Finally, to normalize for the starting point, we consider all cyclic rotations of the first difference and choose among them the lexicographically smallest such code. The resulting code is called the shape number.
00110026202011676122
01100262020116761220
11002620201167612200

20011002620201167612
In this case, 00110026202011676122 is the shape number of the shape above.
Input
The input consists of a number of cases. The input of each case is given in one line, consisting of a chain code of a shape. The length of the chain code is at most 300,000, and all digits in the code are between 0 and 7 inclusive. The contour may intersect itself and needs not trace back to the starting point.
Output
For each case, print the resulting shape number after the normalizations discussed above are performed.
Sample Input
22234446466001207560
12075602223444646600
Sample Output
00110026202011676122
00110026202011676122

题意:给你一个串 新串每个字母是旧串的(两位相减+8)%8,再求最小表示法

#include 
using namespace std;

int a[300100];


int getMax(int a[], int n)
{
    int i, j, k;
    for(i = 0, j = 1; i<>=n)
            break;
        if(a[i+k]>s)
    {
        int len=s.length();
        for(int i=0;i
        
   
相关TAG标签
上一篇:python把一个随机长度整数组分成两组的差值最小
下一篇:四、ElasticSearch5.5.2安装使用Kibana监控及配置
相关文章
图文推荐

关于我们 | 联系我们 | 广告服务 | 投资合作 | 版权申明 | 在线帮助 | 网站地图 | 作品发布 | Vip技术培训 | 举报中心

版权所有: 红黑联盟--致力于做实用的IT技术学习网站