Poj 2160 Box simulation and poj2160box Simulation

Source: Internet
Author: User

Poj 2160 Box simulation and poj2160box Simulation

Question:

Give the length of six boards to determine whether they can form a cube.

Analysis:

Simulation, first determine whether the six boards can be divided into three groups of completely equal boards, and then determine whether the three groups of boards can form a cube.

Code:

// Poj 2160 // sep9 # include <iostream> # include <algorithm> using namespace std; int vis [8]; int x [8], y [8]; int a [8]; int main () {int I, j; for (I = 0; I <6; ++ I) {scanf ("% d ", & x [I], & y [I]); if (x [I]> y [I]) swap (x [I], y [I]);} int cnt = 0, t = 0; memset (vis, 0, sizeof (vis); for (I = 0; I <6; ++ I) {if (vis [I] = 0) {vis [I] = 1; for (j = 0; j <6; ++ j) if (vis [j] = 0 & x [j] = x [I] & y [j] = y [I]) {vis [j] = 1; a [t ++] = x [I]; a [t ++] = y [I]; ++ cnt; break ;}}if (cnt = 3) {sort (a, a + 6 ); if (a [0] = a [1] & a [2] = a [3] & a [4] = a [5]) printf ("POSSIBLE"); elseprintf ("IMPOSSIBLE");} elseprintf ("IMPOSSIBLE ");}


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.