This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
#include <string> | |
#include <map> | |
#include <vector> | |
using namespace std; | |
int N; | |
char News[15][40]; | |
int ans[20]; | |
bool choosed[20] = {0}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
#include <vector> | |
#include <algorithm> | |
using namespace std; | |
int T, N, List[20]; | |
vector<int> ans[10000]; | |
int nOfans; | |
void backtracking(int pos, int sum) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
using namespace std; | |
int prime[] = {2,3,5,7,11,13,17,19,23,29,31,37,41}; | |
int N, Case = 0, ans[20] = {1}; | |
bool isPrime(int a) | |
{ | |
for (int n : prime) | |
if (n == a) return true; | |
return false; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
#include <vector> | |
using namespace std; | |
int Container[8]; | |
int Queens_row[100][8]; | |
int nOfQueens = 0; | |
// col[i]表示該欄是否已經被選, 同理left表示左斜線, right表示右斜線 | |
bool row[8] = {0}, left[15] = {0}, right[15] = {0}; | |
// 底下 r表示row c表示colum |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
#include <vector> | |
using namespace std; | |
int track[21]; | |
int N, T; // T is number of tracks | |
vector<int> Container; // 遞迴時暫存track | |
vector<int> Ans; | |
int Maxsum; | |
void combination(int pos, int sum); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
using namespace std; | |
int board[9][9]; | |
int n, N; // n是較小的邊長, N = n * n | |
bool backtracking(int r, int c); | |
int main() | |
{ | |
int Case = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
#include <algorithm> | |
using namespace std; | |
int N, S[100], choosed[100], ans[100]; | |
void func(int len, int pos) | |
{ | |
if (len == 6){ | |
for (int i = 0; i < 5; ++i) | |
printf("%d ", ans[i]); | |
printf("%d\n", ans[5]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
#include <vector> | |
using namespace std; | |
int P[1000][9]; | |
int tmp[8]; | |
int n = 0; | |
// col[i]表示該欄是否已經被選, 同理left表示左斜線, right表示右斜線 | |
bool col[8] = {0}, left[15] = {0}, right[15] = {0}; | |
// 底下 r表示row c表示colum |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
#include <vector> | |
using namespace std; | |
void DFS(int n, int visit[], vector<int> toNode[], vector<int> &ans); | |
int main() | |
{ | |
int N, M, a, b; | |
while (scanf("%d %d", &N, &M) && (N || M)) { | |
vector<int> toNode[101]; | |
vector<int> ans; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <cstdio> | |
#include <string> | |
#include <vector> | |
using namespace std; | |
vector<char> ans; | |
vector<char> toPoint[100]; | |
int visit[100] = {0}; | |
int deg[100] = {0}; // deg[i]=1:沒有被其他點連入 deg[i]=2:被其他點連入 |