摘要:
trie树。这题学会的:1.strtok(char * st1, char*st2)用st2分割st1,损坏原串,返回分割后的第一个串的指针,想获得被分割的第二个串则需要调用第二次,并且第一个参数给NULL2.unget(ch, stdin);可以把读到的字符ch放回到输入文件中去。相当于getchar()的你过程。3.树状结构频繁开辟指针空间浪费时间,可以直接开辟节点数组,并让指针指向数组中的未使用位。View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <c 阅读全文
posted @ 2011-05-16 19:51
undefined2024
阅读(615)
评论(0)
推荐(0)
摘要:
简单dpView Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;int main(){ //freopen("t.txt", "r", stdin); int t; scanf("%d", &t); while (t--) { int a, b, c, d, e, f, g, h, n, fun[1005]; scanf(" 阅读全文
posted @ 2011-05-16 18:50
undefined2024
阅读(128)
评论(0)
推荐(0)
摘要:
简单题View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;#define maxl 50char w1[maxl], w2[maxl];int f1[26], f2[26];void work(char *w, int *f){ int len = strlen(w); for (int i = 0; i < len; i++) f[w[i] - 'a']++;}int ma 阅读全文
posted @ 2011-05-16 16:50
undefined2024
阅读(177)
评论(0)
推荐(0)
摘要:
递推,注意f[0] = 1;View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;#define maxn 31int main(){// freopen("t.txt", "r", stdin); int f[maxn] = {1,0,3,0}; for (int i = 4; i < maxn; i++) { f[i] = f[i - 2] * 3; 阅读全文
posted @ 2011-05-16 16:06
undefined2024
阅读(254)
评论(0)
推荐(0)
摘要:
高精度,java快要忘没了。java使用文件输入要抛出异常。View Code import java.util.*;import java.io.*;import java.math.*;public class Main { static int[] prm = new int[1000000]; static boolean[] is = new boolean[1000000]; static int getprm(int n) { int i, j, k = 0; int s, e = (int) (Math.sqrt(0.0 + n) + 1); for (i = 0; i < 阅读全文
posted @ 2011-05-16 15:36
undefined2024
阅读(357)
评论(0)
推荐(0)
摘要:
快排,注意保留一位小数。View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>#include <algorithm>#include <cmath>using namespace std;#define maxn 250005int n;long long f[maxn], sum;int main(){ //freopen("t.txt", "r", stdin); sc 阅读全文
posted @ 2011-05-16 14:21
undefined2024
阅读(241)
评论(0)
推荐(1)
摘要:
简单模拟View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;#define maxn 11int n;bool map[maxn][maxn], touched;char out[maxn][maxn];void input(){ for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { char ch = getchar( 阅读全文
posted @ 2011-05-16 13:58
undefined2024
阅读(194)
评论(0)
推荐(0)
摘要:
简单题View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;int s[] = { 0, 1, 2, 3, 0, 1, 2, 0, 0, 2, 2, 4, 5, 5, 0, 1, 2, 6, 2, 3, 0, 1, 0, 2, 0, 2 };int main(){ //freopen("t.txt", "r", stdin); string st; while 阅读全文
posted @ 2011-05-16 13:27
undefined2024
阅读(179)
评论(0)
推荐(0)