Результат MediaWiki API

This is the HTML representation of the JSON format. HTML is good for debugging, but is unsuitable for application use.

Specify the format parameter to change the output format. To see the non-HTML representation of the JSON format, set format=json.

See the complete documentation, or the API help for more information.

{
    "warnings": {
        "query": {
            "*": "Formatting of continuation data has changed. To receive raw query-continue data, use the 'rawcontinue' parameter. To silence this warning, pass an empty string for 'continue' in the initial query."
        }
    },
    "batchcomplete": "",
    "continue": {
        "gapcontinue": "SAT",
        "continue": "gapcontinue||"
    },
    "query": {
        "pages": {
            "527": {
                "pageid": 527,
                "ns": 0,
                "title": "Reviews/VasilyKorchagin/TSP",
                "revisions": [
                    {
                        "contentformat": "text/x-wiki",
                        "contentmodel": "wikitext",
                        "*": "<code-python>\n#!/usr/bin/python2\n# -*- coding: utf8 -*-\n\nfrom itertools import permutations\n\ndef TSP_bool(n, D, B):\n    \"\"\"\n    \u0412\u0435\u0440\u043d\u043e \u043b\u0438, \u0447\u0442\u043e \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u0443\u043c\u043c\u044b \u043c\u0435\u043d\u044c\u0448\u0435 B?\n    \"\"\"\n    for p in permutations(xrange(1, n)): # \u041f\u0435\u0440\u0435\u0431\u043e\u0440 \u0432\u0441\u0435\u0445 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043d\u043e\u0432\u043e\u043a\n        length = D[0][p[0]] # \u041f\u0440\u0438\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u0443\u0442\u044c \u0438\u0437 \u043f\u0435\u0440\u0432\u043e\u0439 \u0432\u0435\u0440\u0448\u0438\u043d\u044b\n        if length  > 0 and D[p[-1]][0] > 0: # \u041f\u0443\u0442\u044c p \u0441\u0432\u044f\u0437\u0435\u043d \u0441 v0\n            found = True\n            for i in xrange(len(p) - 1):\n                if D[p[i]][p[i + 1]] == -1: # \u041d\u0435\u0442 \u0442\u0430\u043a\u043e\u0433\u043e \u0440\u0435\u0431\u0440\u0430\n                    found = False # \u041f\u0443\u0442\u044c \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\n                    break\n                length += D[p[i]][p[i + 1]]\n                if length > B: # \u0415\u0441\u043b\u0438 \u0441\u0443\u043c\u043c\u0430 \u0431\u043e\u043b\u044c\u0448\u0435 B, \u0442\u043e \u043f\u0443\u0442\u044c \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\n                    found = False\n                    break\n            #print found\n            if found:\n                # \u041f\u0440\u0438\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u0443\u0442\u044c \u0438\u0437 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u0432\u0435\u0440\u0448\u0438\u043d\u044b \u0432 \u043f\u0435\u0440\u0432\u0443\u044e\n                if length + D[p[-1]][0] < B:\n                    return True, p\n    return False, ()\n\ndef TSP(n, D):\n    B_min = 0\n    # n \u0443\u043c\u043d\u043e\u0436\u0438\u0442\u044c \u043d\u0430 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u0432\u0435\u0441\n    B_max = n * max([inner for outer in D for inner in outer])\n    true_path = ()\n    while B_max - B_min > 1:\n        B = (B_min + B_max) / 2\n        tsp_bool, path = TSP_bool(n, D, B)\n        if tsp_bool:\n            true_path = path\n            B_max = B\n        else:\n            B_min = B\n    if TSP_bool(n, D, B_min)[0]:\n        return B_min, true_path\n    return B_max, true_path\n\nD = [\n [0 , 15, 20, 15, -1],\n [15, 0 , 50, 10, 60],\n [20, 50, 0 , 30, 50],\n [15, 10, 30, 0 , 80],\n [-1, 60, 50, 80, 0 ]\n]\n\nprint TSP(5, D)\n</code-python>\n\n\n== \u0417\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u044f ==\n* \u041e\u0442 \u043b\u0438\u0448\u043d\u0435\u0439 \u043f\u0443\u043d\u043a\u0442\u0443\u0430\u0446\u0438\u0438 \u043d\u0430\u0434\u043e \u0438\u0437\u0431\u0430\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u2014 \u044d\u0442\u043e \u0436\u0435 \u043f\u0438\u0442\u043e\u043d, \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b \u0438 \u0447\u0438\u0442\u0430\u0435\u043c\u043e\u0441\u0442\u0438.\n** <tt>;</tt> \u043d\u0435 \u043d\u0443\u0436\u043d\u044b.\n** \u043b\u0438\u0448\u043d\u0438\u0435 \u0441\u043a\u043e\u0431\u043a\u0438 \u0432\u043e\u043a\u0440\u0443\u0433 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0445 tuples \u043d\u0435 \u043d\u0443\u0436\u043d\u044b.\n** \u00ab\u043f\u0440\u043e\u0434\u043b\u0435\u043d\u0438\u044f \u0441\u0442\u0440\u043e\u043a\u00bb <tt>\\</tt> \u0432\u043d\u0443\u0442\u0440\u0438 \u0441\u043a\u043e\u0431\u043e\u0447\u043d\u044b\u0445 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439 \u043d\u0435 \u043d\u0443\u0436\u043d\u044b.\n\n* <tt>sum</tt> \u2014 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u043d\u0430\u0434\u043e \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u0442\u044c \u043f\u043e-\u0434\u0440\u0443\u0433\u043e\u043c\u0443.\n* <tt>continue</tt>, <tt>break</tt> \u2014 \u044d\u0442\u043e \u043f\u043e\u0447\u0442\u0438 \u0447\u0442\u043e \u00abgoto\u00bb, \u0438\u0445 \u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0438\u0437\u0431\u0435\u0433\u0430\u0442\u044c, \u0442\u0443\u0442 \u044d\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e.\n* \u0412\u0441\u0435 \u043b\u0438\u0448\u043d\u0435\u0435 \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u043a\u0438\u0434\u044b\u0432\u0430\u0442\u044c. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u00abelse-\u0432\u0435\u0442\u0432\u044c\u00bb \u0432 \u043a\u043e\u043d\u0446\u0435.\n* n \u2014 \u044d\u0442\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u00ab\u043c\u0430\u0442\u0440\u0438\u0446\u044b\u00bb D, \u0433\u043e\u043d\u044f\u0442\u044c \u0435\u0433\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c \u2014 \u043e\u0442\u0441\u0442\u043e\u0439.\n\n== \u0413\u043b\u0430\u0432\u043d\u043e\u0435 ==\n* \u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u043d\u0435\u0432\u0435\u0440\u043d\u0430.\n* \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442:\n (156, (2, 4, 1, 3))\n\u2014 \u043f\u043e \u043c\u0430\u0442\u0440\u0438\u0446\u0435 \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u0441\u0440\u0430\u0437\u0443 \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u043d\u0438 \u043e\u0434\u0438\u043d \u043f\u0443\u0442\u044c \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0441\u0442\u043e\u0438\u0442\u044c 156 (\u0434\u043e\u043b\u0436\u0435\u043d \u0434\u0435\u043b\u0438\u0442\u0441\u044f \u043d\u0430 5)."
                    }
                ]
            },
            "3586": {
                "pageid": 3586,
                "ns": 0,
                "title": "Rimon/Ada and Manure",
                "revisions": [
                    {
                        "contentformat": "text/x-wiki",
                        "contentmodel": "wikitext",
                        "*": "https://www.spoj.com/problems/ADADUNG/\n\nC++(gcc8.3)\n\n<code-cpp>\n\n#include <iostream>\n#include <stdio.h>\n#include <string>\n#include <vector>\n#define ulli unsigned long long int\nusing namespace std;\n\nint t, n;\nulli rs[10000001];\n\n\ninline void inp( int &n )\n{\n   n=0;\n   int ch=getchar_unlocked();int sign=1;\n   while(ch < '0' || ch > '9' ){if(ch=='-')sign=-1; ch=getchar_unlocked();}\n   while(ch >= '0' && ch <= '9' )\n           n = (n<<3)+(n<<1) + ch-'0', ch=getchar_unlocked();\n   n=n*sign;\n}\n\n\nvoid dp() {\n    ulli tmp = 1;\n    rs[1] = 0;\n    rs[2] = 1;\n    rs[3] = 2;\n    for (int i = 4; i < 10000001; i++) {\n        rs[i] = (rs[i-1] * i + tmp) % 1000000007;\n        tmp = tmp * (-1);\n    }\n}\n\nint main() {\n    dp();\n    inp(t);\n    for (int z = 0; z < t; z++) {\n        inp(n);\n        cout << rs[n] << \"\\n\";\n    }\n    return 0;\n}\n</code-cpp>"
                    }
                ]
            }
        }
    }
}