How to replace the Android system image system.img

Source: Internet
Author: User

That was the 8 queen question, the recursive way of writing, and then this can ask the N queen to put the problem, using the purely mathematical method ... Magic!

#include <iostream> #include <cstdio> #include <fstream> #include <algorithm> #include < cmath> #include <deque> #include <vector> #include <list> #include <queue> #include < string> #include <cstring> #include <cstdlib> #include <map> #include <stack> #include < set> #define PI ACOs ( -1.0) #define MEM (A, B) memset (A,b,sizeof (a)) #define SCA (a) scanf ("%d", &a) #define SC (A, B) scanf ("%d%d", &a,&b) #define PRI (a) printf ("%d\n", a) #define Lson i<<1,l,mid#define Rson I<<1|1,mid +1,r#define MM 1000005#define MN 2005#define INF 100004#define eps 1e-7using namespace std;typedef long long ll;//output is the current column     Which line needs to place the Queen//For example: 5 3 1 6 8 2 4 7//that is, the first column of the fifth row placed Queen, the second column of the third row placed Queen void Solvequeen (int n)//n Queen question {int k,i,first=1;        if (n%6!=2&&n%6!=3) {for (i=2;i<=n;i+=2) printf ("%d", I);    for (i=1;i<=n;i+=2) printf ("%d", I);        } else {K=N/2; if (! (            k&1)) {for (i=k;i<=n;i+=2) printf ("%d", I);            for (i=2;i<=k-2;i+=2) printf ("%d", I);            for (i=k+3;i<=n-1;i+=2) printf ("%d", I);            for (i=1;i<=k+1;i+=2) printf ("%d", I);        if (n&1) printf ("%d", n);            } else {for (i=k;i<=n-1;i+=2) printf ("%d", I);            for (i=1;i<=k-2;i+=2) printf ("%d", I);            for (i=k+3;i<=n;i+=2) printf ("%d", I);            for (i=2;i<=k+1;i+=2) printf ("%d", I);        if (n&1) printf ("%d", n); }} puts ("");}    int main () {int n;    while (SCA (n) &&n) Solvequeen (n); 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.