FOJ 1402 (DP push law)

Source: Internet
Author: User

Push the rules.
/**1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 212 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 223 5 7 9 11 1 3 15 17 19 21 23 25 27 29 31 33 35 37 39 41 430 1 25 13 29 61 125 253 509 1021 2045 4093 8189 16381 32765 65533 131069 262  141 524285 48570 97143 194289 3885811 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 7 3 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 2 3 4 5 6 7 8 9 10 11 12 13 14 15  16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 9  7 98 99 100 101 1023 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97 99 101 103 105 107 109 111 113 115 117 119 121 123 125 127 129 131 133 135 137 139 141 143 145 147 149 151 15 3 155 157 159 161 163 165 167 169 171 173 175 177 179 181 183 185 187 189 191 193 195 197 199 201 203 5 13 29 61 125 253 5 09 1021 2045 4093 8189 16381 3276565533 131069 262141 524285 48570 97143 194289 388581 777165 554330 108660 217323 434649 869301 738602 477204 954411 908822 817644 635288 270576 541155 82310 164623 329249 658501 317002 634007 268014 536031 7206 2 144127 288257 576517 153034 306071 612145 224290 448583 897169 794338 588676 177352 354707 709417 418834 837671 675342 3 50684 701371 402742 805487 610974 221948 443899 887801 775602 551204 102408 204819 409641 819285 638570 277140 554283 1085 66 217135 434273 868549 737098 474196 948395 896790 793580 587160 174320 348643 697289 394578 789159 578318 156636 313275 626553 253106 506215 12430 248632 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 223 5 7 9 11 13 15 17 19 21 23 25 27 2 9 31 33 35 37 39 41 43513 29 61 125 253 509 1021 2045 4093 8189 16381 32765 65533 131069 262141 524285 1048573 (18) 2097149 4194301 83886050 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 002 3 4 5 6 7 8 9 10 11  17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 9  8 99 100 101 1023 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97 99 101 103 105 107 109 111 113 115 117 119 121 123 125 127 129 131 133 135 137 139 141 1 43 145 147 149 151 153 155 157 159 161 163 165 167 169 171 173 175 177 179 181 183 185 187 189 191 193 195 197 199 201 203 5 13 29 61 125 253 509 1021 2045 40938189 16381 32765 65533 131069 262141 524285 1048573 2097149 4194301 8388605 16777213 33554429 67108861 134217725 268435453  536870909 1073741821 2147483645-3-3-3-3-3-3-3-3-3-3-3-3-3-3-3-3-3-3-3-3-3-3-3-3-3  -3-3-3-3-3-3-3-3-3-3-3-3-3-3-3-3-3-3-3-3-3-3-3-3-3-3-3-3-3-3-3-3-3-3  -31 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 8 4 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 1012 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 2 7 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 1023 5 7 9 11 13 1 5 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97 99 101 103 105 107 10 9 111 113 115 117 119 121 123 125 127 129 131 133 135 137 139 141 143 145 147 149 151 153 155 157 159 161 163 165 167 169 171 173 175 177 179 181 183 185 187 189 191 193 195 197 199 201 2035 13 29 61 125 253 509 1021 2045 4093 8189 16381 32765  65533 131069 262141 524285 48570 97143 194289 388581 777165 554330 108660 217323 434649 869301 738602 477204 954411 908822 817644 635288 270576 541155 82310 164623 329249 658501 317002 634007 268014 536031 72062 144127 288257 576517 153034 3060 71 612145 224290 448583 897169 794338 588676 177352 354707 709417 418834 837671 675342 350684 701371402742 805487 610974 2 21948 443899 887801 775602 551204 102408 204819 409641 819285 638570 277140 554283 108566 217135 434273 868549 737098 4741 96 948395 896790 793580 587160 174320 348643 697289 394578 789159 578318 156636 313275 626553 253106 506215 12430 24863*// **5 13 29 61 125 253 509 1021 2045 4093 8189 16381 32765 65533 131069 262141 524285 1048573 2097149 4194301 8388605 16777213 33554429 67108861 134 217725a[3][0] = a[2][1] = 5;a[3][1] = a[2] a[a[3][0]] = a[2][5] = 13;a[3][2] = a[2][) = 29;a[3][3] = a[2][29] = 1,52,13 3,29 1, 1*2+3 n*2+3 2, 5*2+3 (n*2+3) * + 3 n*2*2 + 3*2 +, 13*2+3 ((n*2+3) * + 3) * + 3 n*2*2*2 + 3*2*2 + 3*2 + 33+6+12+4, 29*2+3 (((n*2+3) * + 3) * * + 3) * * + 3 1*2*2*2*2 + 3*2*2*2 + 3*2*2 + 3*2 +3 N, 2 (n) + (1-2 (n))/ -12 (n) + 2 (n)-1) 4*2 (n) -3a[m-1][]3* (1-2*2 (n))/(1-2) =3* (-15)/-1 = 45 + 16 = 6161*//**5 13 29 61 12 5 253 509 1021 2045 4093 8189 16381 32765 65533 131069 262141 524285 1048573 2097149 4194301 8388605 6777210 (22) 3554420 (2 3) 7108843 (4217686) *//***a[3][22] = a[2][a[3][21]] = a[2][8388605] = 13;a[3]*/#include <iostream> #include <cstdio>using namespace Std;int Ackermann (int m,int n) {if (m==1) {return 2+n;} else if (m==2) {return 3+2*n;} else if (m==3) {if (n>0) return AcKermann (2,ackermann (m,n-1)); else if (n==0) {return Ackermann (2,1);}} return 0;} int main () {//for (int i=0;i<=3;i++) {//for (int j=0;j<=100;j++) {//printf ("%d", Ackermann (i,j)); }//printf ("\ n");//}for (int i=0;i<=24;i++) printf ("%d", Ackermann (3,i)); return 0;} /**134217725*//**A[3][24] = a[2][a[3][23]]4217686*/
#include <cstdio> #include <algorithm> #include <cstring>using namespace Std;int a[4][100000000 + 10];            int main () {for (int. i=0;i<=3;i++) {for (int j=0;j<=100000000;j++) {if (i==0) a[i][j]=j+1;            else if (i>0&&j==0) a[i][j]=a[i-1][1];        else if (i>0&&j>0) a[i][j]=a[i-1][a[i][j-1]];    }} for (int j=0;j<=1000000;j++) a[0][j]=j+1; A[1][0]=2;A[1][1] = a[0][A[1][0]] = 3;  A[1][2] = a[0][a[1][1]]=4;    A[1][3] = a[0][a[1][2]] = 5;    for (int j=1;j<=1000000;j++) a[1][j] = a[0][a[1][j-1]]; A[2][0]=A[1][1] = 3;    A[2][1] = a[1][a[2][0]] = 5; for (int j=1;j<=1000000; j + +) a[2][j]=a[1][A[2][j-1]];//for (int. i=0;i<=3;i++) {//for (int j=0;j<=100; J + +) {//printf ("%lld", A[i][j]);//}//printf ("\ n");////} printf ("%lld", a[1][1000001])    ;    a[2][500000] = a[1][a[2][500000-1]] = a[1][1000001]; A[1][1000001] = a[0][a[1][1000000]] n=2;    m=1000000; a[2][1000000] = a[1][a[2][]]//int m,n;//while (scanf ("%d%d", &m,&n)!=eof) {//printf ("%lld\n", a[ M][n]);//} return 0;}
#include <cstdio> #include <algorithm> #include <cstring>using namespace Std;int a[4][100000000 + 10]; int main () {for    (int. i=0;i<=3;i++) {for        (int j=0;j<=100000000;j++) {            if (i==0) a[i][j]=j+1;            else if (i>0&&j==0) a[i][j]=a[i-1][1];            else if (i>0&&j>0) a[i][j]=a[i-1][a[i][j-1]];        }    }    for (int i=0;i<=24;i++)//    printf ("%d", A[3][i]);    int m,n;    while (scanf ("%d%d", &m,&n)!=eof) {        printf ("%d\n", A[m][n]);    }     for (int i=0;i<=10;i++) {//        for (int j=0;j<=10;j++) {//                printf ("%d", a[i][j]);//        }//        printf ("\ n");/    }    return 0;}

Ac

#include <cstdio> #include <algorithm> #include <cstring> #include <cmath>using namespace std; int pp[25]={};int A (int m,int n) {    if (m==0) return n+1;    else if (m==1) return n+2;    else if (m==2) return 2*n+3;    else if (m==3) return a (2, 4*floor (POW (2,n) +0.5)-3)  ;} int main () {     int m,n;    while (scanf ("%d%d", &m,&n)!=eof) {        printf ("%d\n", A (m,n));    }    return 0;}



Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

FOJ 1402 (DP push law)

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.