Ultraviolet A 716, ultraviolet

Source: Internet
Author: User

Ultraviolet A 716, ultraviolet

Link to the question: Ultraviolet A 716-Commedia dell 'arte

Given a three-dimensional octal digital, 0 represents an empty position and asks if it can be sorted back.

Solution: for the case where n is an odd number, consider the reverse logarithm of the three-dimensional octal digital to consider the case where the State goes down, except 0, and the even number, consider transferring the position of 0 to (n, the reverse logarithm of the corresponding sequence after the n, n) position. If the reverse logarithm is an even number, the odd number is not allowed.

#include <cstdio>#include <cstring>#include <algorithm>using namespace std;typedef long long ll;const int maxn = 1e6+5;int n, arr[maxn], t[maxn];int x, y, z;ll merge_sort (int l, int r, int* a, int* b) {    if (l == r)        return 0;    ll ret = 0;    int mid = (r + l) / 2;    int p = l, q = mid+1, mv = l;    ret = merge_sort(l, mid, a, b) + merge_sort(mid + 1, r, a, b);    while (p <= mid || q <= r) {        if (q > r || (p <= mid && a[p] < a[q]))            b[mv++] = a[p++];        else {            ret += mid - p + 1;            b[mv++] = a[q++];        }    }    for (int i = l; i <= r; i++)        a[i] = b[i];    return ret;}bool judge () {    if (n&1) {        ll ret = merge_sort(0, n*n*n-1, arr, t) - (z * n * n + x * n + y - 1);        return (ret&1) == 0;    }    while (z != n - 1) {        int p = z * n * n + x * n + y;        z++;        int q = z * n * n + x * n + y;        swap(arr[p], arr[q]);    }    while (x != n - 1) {        int p = z * n * n + x * n + y;        x++;        int q = z * n * n + x * n + y;        swap(arr[p], arr[q]);    }    while (y != n - 1) {        int p = z * n * n + x * n + y;        y++;        int q = z * n * n + x * n + y;        swap(arr[p], arr[q]);    }    ll ret = merge_sort(0, n*n*n-2, arr, t);    return (ret&1) == 0;}int main () {    int cas;    scanf("%d", &cas);    while (cas--) {        scanf("%d", &n);        for (int k = 0; k < n; k++) {            int Z = k * n * n;            for (int i = 0; i < n; i++) {                int X = i * n;                for (int j = 0; j < n; j++) {                    int tmp = Z + X + j;                    scanf("%d", &arr[tmp]);                    if (arr[tmp] == 0) {                        x = i; y = j; z = k;                    }                }            }        }        printf("%s\n", judge() ? "Puzzle can be solved." : "Puzzle is unsolvable.");    }    return 0;}

What kind of sunscreen is recommended? Do you know?

Different wavelengths of ultraviolet rays have different depth of penetration into the skin. UVC reflects and absorbs the stratum corneum, and only a small part of it passes through the superficial epidermis. However, when UVC passes through the atmosphere, it is mostly absorbed by the ozone layer and cannot reach the Earth's surface. Therefore, it does not pose any harm to human skin. Most of the ultraviolet rays are absorbed by the skin, and a small part of them reach the superficial dermis, which is the main band of skin damage. It is carcinogenic, but can be blocked by thick clouds, clothing and glass. A small part of ultraviolet A is absorbed by the skin, and most of them can be penetrated into the dermis, reaching the middle Of the dermis. At noon in the summer, the amount of ultraviolet A rays that reach the Earth's surface is 100 times more than that of ultraviolet B rays, which can penetrate the skin to the dermis and cause dermis damage. Therefore, it is the main ultraviolet disease spectrum. The main damage caused by ultraviolet rays to the skin is:

What is the largest province in Russia?

Belgorod Obl. 1,511,620 27,100 Belgorod 337,030

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.