UV problem 10182 bee Maja (Maja)

Source: Internet
Author: User
Tags dot net
// Bee Maja (BEE Maja) // PC/Ultraviolet IDs: 111204/10182, popularity: B, success rate: high level: 2 // verdict: accepted // submission date: 2011-11-01 // UV Run Time: 0.012 S // copyright (c) 2011, Qiu. Metaphysis # Yeah dot net // [solution] // simulate the movement of bee Willi and generate coordinates based on the laws of the two coordinate systems. The rule is: the number on each side is the same as the number on each side. Six sides of the 12 numbers, such as 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, and 9. The lower left side is composed of 9, 10, and 11, and the abscissa is reduced by one in turn, the ordinate coordinates remain unchanged. For other edges, there is a similar law. The exception is that the lower right edge has only 8 to 9 numbers, and the number that makes up the edge needs to be specially processed. Select 1, 2, 9, // 22,... for the starting beehive number during processing. The difference between adjacent numbers forms an equal difference sequence with an initial item of 1 and a difference of 6. Due to the initial processing of the beehive number relationship, you need to relax the number of the beehive coordinates to be calculated. Otherwise, some beehive numbers cannot be calculated due to the circular relationship. # Include <iostream> # include <set> using namespace STD; # define maxn 100200int offset [5] [2] = {-1, 0}, {0, -1 },{ 1,-1 },{ 1, 0 },{ 0, 1 }}; pair <int, int> Maja [maxn + 2000]; int main (int ac, char * AV []) {for (INT I = 1, j = 1, K = 0; I <maxn; I ++ = J, J + = 6, K ++) {Maja [I] = make_pair (0, k); For (INT m = 0; m <K; m ++) maja [I-m] = make_pair (M, K-m); int current = I; for (INT m = 0; m <5; m ++) for (INT n = 0; n <K; n ++) {int x = Maja [current]. first + offset [m] [0]; int y = Maja [current]. second + offset [m] [1]; Maja [current + 1] = make_pair (x, y); current ++ ;}} int Willi; while (CIN> Willi) cout <Maja [Willi]. first <"" <Maja [Willi]. second <Endl; return 0 ;}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.