#include<iostream>

#include<vector>

using namespace std;

int countNqueen(int size);

int nqueen(int row, int size, vector<int>& conquer);

int main(){

int testCase;

cin >> testCase;

 

while(testCase--){

int size;

cin >> size;

 

cout << countNqueen(size) << endl;

}

 

return 0;

}

int countNqueen(int size){

vector<int> conquer(size, -1);

int result = 0;

 

for(int i=0; i<size/2; i++){

conquer[i] = 0;

result += nqueen(1, size, conquer);

conquer[i] = -1;

}

 

result *= 2;

 

if(size % 2 != 0){

conquer[size/2] = 0;

result += nqueen(1, size, conquer);

}

 

return result;

}

int nqueen(int row, int size, vector<int>& conquer){

if(row == size) return 1;

 

int result = 0;

 

for(int i=0; i<size; i++){

if(conquer[i] == -1){

bool isSafe = true;

for(int j=i-1; j>i-1-row; j--){

if(j >= 0 && j < size && (i - j == row - conquer[j]))

isSafe = false;

}

for(int j=i+1; j<i+1+row; j++){

if(j >= 0 && j < size && (j - i == row - conquer[j]))

isSafe = false;

}

if(isSafe){

conquer[i] = row;

result += nqueen(row+1, size, conquer);

conquer[i] = -1;

}

}

}

 

return result;

}

[출처] 알고스팟 초보용 탐색 NQUEEN|작성자 nalchang

 

출처: <http://blog.naver.com/PostView.nhn?blogId=hades2015&logNo=220419968223&parentCategoryNo=&categoryNo=&viewDate=&isShowPopularPosts=false&from=postView>

 

프로젝트 정보

-프로젝트현대캐피탈 앱 개발 

-근무지 : 국회의사당역

-필요인원 :  ios 중급 1

-기간 : 41  ~ 투입 후 5개월 (5M/M)

-단가 : 500~600만 협의 

-기술 : ios

-기타 :금융권 경험 우대

-제출서류개인 프로필 및 자격증 사본(있을경우) 1부 메일 송부(단가기재필수)

 

 

∙ 담당자 정보

-이메일 : sohee@articleglobal.net

-연락처 : 010-6476-----

 

출처: <https://iphonedev.co.kr/jobOffer/141340#0>

 

 

 

새로운 블로그를 시작하며, 트위터의 내용도 모두 옮기기로 했다. 채널을 하나로 일원화 하는게 내가 편해서. 물론, 모든 내용을 적기엔 힘들다. 트위터나 블로그가 가지는 색이 각기 다르기 때문.

 

 

 

얼마 전, 날 고소하려 했던 사람들이 3000개의 글을 다 읽은 것 빼고는 내 글을 전체적으로 다 보았다는 사람은 보지 못했다. 고소 관련해서도 여기 썰을 풀 것이다. 읽고 싶은 사람에게 "간접경험"을 제공하기 위해.

 

 

 

 

 

 

 

 

 

 

 

C:\Windows\System32\shutdown.exe -f -s -t 0

복수영화

https://www.youtube.com/watch?v=D0l9Fxk27Cg

The Revenant, 2015

 

출처: <https://www.youtube.com/watch?v=mFNgEYYHgk4>

      1. Setuid 뭔지 모른다.
      2. Find ctime 뭔지 모른다.
      3. stackshare.io

4...

 

레버넌트: 죽음에서 돌아온 자

 

 

A non-empty zero-indexed array A consisting of N integers is given. The array contains an odd number of elements, and each element of the array can be paired with another element that has the same value, except for one element that is left unpaired.

For example, in array A such that:

A[0] = 9 A[1] = 3 A[2] = 9 A[3] = 3 A[4] = 9 A[5] = 7 A[6] = 9

  • the elements at indexes 0 and 2 have value 9,
  • the elements at indexes 1 and 3 have value 3,
  • the elements at indexes 4 and 6 have value 9,
  • the element at index 5 has value 7 and is unpaired.

Write a function:

class Solution { public int solution(int[] A); }

that, given an array A consisting of N integers fulfilling the above conditions, returns the value of the unpaired element.

For example, given array A such that:

A[0] = 9 A[1] = 3 A[2] = 9 A[3] = 3 A[4] = 9 A[5] = 7 A[6] = 9

the function should return 7, as explained in the example above.

Assume that:

  • N is an odd integer within the range [1..1,000,000];
  • each element of array A is an integer within the range [1..1,000,000,000];
  • all but one of the values in A occur an even number of times.

Complexity:

  • expected worst-case time complexity is O(N);
  • expected worst-case space complexity is O(1), beyond input storage (not counting the storage required for input arguments).

Elements of input arrays can be modified.

Copyright 2009–2016 by Codility Limited. All Rights Reserved. Unauthorized copying, publication or disclosure prohibited.

 

출처: <https://codility.com/demo/results/trainingTSBMRV-526/>

 

// you can also use imports, for example: // import java.util.*; // you can write to stdout for debugging purposes, e.g. // System.out.println("this is a debug message"); class Solution { public int solution(int[] A) { // write your code in Java SE 8 int cnt=0; for(int i=0; i < A.length; i++) { for(int j=0; j < A.length ; j++) { if(A[i] == A[j]) cnt++; } if(cnt == 1) return A[i]; else cnt = 0; } return A[0]; } }

 

class Solution { public int solution(int[] A) { // write your code in Java SE 8 int ret=0; for(int i=0; i < A.length; i++) { ret ^= A[i]; } return ret; } }

 

출처: <https://codility.com/demo/results/trainingTSBMRV-526/>

'Blog History' 카테고리의 다른 글

177  (0) 2020.04.14
176  (0) 2020.04.14
174  (0) 2020.04.14
173  (0) 2020.04.14
172  (0) 2020.04.14

+ Recent posts