n皇后
摘要:n*n中选8个-->每行皇后选一列,用c[x]来存储列编号,枚举量为8!=40320void search(int cur){ if(cur == n) tot ++; else for(int i = 0; i < n; i ++) { int ok =...
阅读全文
子集生成
摘要:1.增量构造法view codevoid print_subset(int n, int* a, int cur){ for(int i = 0; i < cur; i++) printf("%d",a[i]); //递归一次,打印一次 prin...
阅读全文
排列
摘要://枚举#include int a[100];int n;void premutation(int n,int* a,int cur){ if(cur == n) { for(int i = 0; i const int M...
阅读全文
Uva 10340 All in All
摘要:#include #include char s[100005],t[100005];int main(){ int yes, n = 0; while(scanf("%s%s",s,t)==2) { yes = 1; n = 0; for...
阅读全文
Uva 202 Repeating Decimals
摘要:关键是判断循环的长度,若某一步的余数已出现过,则循环确定#include #include int s[10000], y[10000],sign[10000];int main(){ int a, b, sz, yu, k , cnt; while(scanf("%d%d",&a,&b...
阅读全文
Uva 1368-DNA Consensus String
摘要:本题只有四个字符,用常量数组存储它们#include #include char a[100][1500];int b[10];int main(){ int cnt, m, n, hamming= 0,maxum = 0; char c[10] ="ACGT"; scanf("%...
阅读全文
Uva 232-crossword answers
摘要:我的思路是网格的四周全部置为'*',设置sign数组记录起始格#include #include char a[20][20];int sign[20][20];int n = 1;int main(){ int r, c, cnt, yes, first = 1; while(scan...
阅读全文
Uva 227-Puzzle
摘要:Puzzle A children's puzzle that was popular 30 years ago consisted of a 5x5 frame which contained 24 small squares of equal size. A unique letter of t
阅读全文
Uva 455-periodic strings
摘要:UVA - 455Periodic StringsTime Limit:3000MSMemory Limit:Unknown64bit IO Format:%lld & %lluSubmitStatusDescriptionPeriodic StringsA character string is ...
阅读全文