上一页 1 ··· 7 8 9 10 11 12 13 14 下一页
  2012年4月9日
摘要: /** 分析:题意要求找字符串个数最多的一个* 方法:很多,hash就是其中一种 * 注意两点:1.去掉前导0; 2.每组测试数据后,要释放内存 * 第一点解析:例如数据01,001,0001, 00001不去前导0的话,hash以后映射到不同的表位置 *//* Author: Try86 Date: 09/04/12 18:01*/#include <cstdio>#include <cstring>#include <iostream>using namespace std;const int M = 5471; //hash表大小struct node 阅读全文
posted @ 2012-04-09 18:37 Try86 阅读(560) 评论(0) 推荐(0)
摘要: //字符串hash练手题,采用拉链式解决冲突 #include <cstdio>#include <cstring>#include <iostream>using namespace std;const int M = 43853;//hash表大小 struct node {//节点 char str1[11]; char str2[11]; node *next; };struct hashTable {//hash表 node *link;}hash[M];char text[3005];char str1[11], str2[11], ch[11] 阅读全文
posted @ 2012-04-09 17:49 Try86 阅读(163) 评论(0) 推荐(0)
  2012年4月6日
摘要: //数论,n!末尾0的个数/*摘自:KIDxの博客N! = 1 * 2 * 3 * (2*2) * 5 * (2*3) * 7... 产生10的原因是有2,5的因子,显然在N!中2的个数大于5的个数,所以只需求出5的个数即可 求 N! (1*2*3*4*5*...*N)里有多少个5其实可以转化成: N!中:是5的倍数的数+是5^2的倍数的数+5^3..... 如50!: 含有10个5的倍数的数:5,15,20,25,30,35,40,45,50 【50/5=10】 含有2个5^2的倍数的数:25,50【50/(5^2)=2】 可见N!中一共有12个5相乘,那么尾0也必有12个 */#inclu 阅读全文
posted @ 2012-04-06 21:00 Try86 阅读(168) 评论(0) 推荐(0)
摘要: //字符串处理#include <cstdio>#include <cstring>#include <iostream>using namespace std;char text[1005];void solve() { int l = strlen(text); int i, j, k; for (i=0; i<l; ) { if (text[i] != ' ') { for (j=i; text[j]!=' ' && j<l; ++j); for (k=j-1; k>=i; --k) p 阅读全文
posted @ 2012-04-06 20:45 Try86 阅读(163) 评论(0) 推荐(0)
  2012年4月5日
摘要: //java大数import java.util.Scanner;import java.math.BigInteger;public class hdu1250{ public static void main(String args[]) { Scanner cin = new Scanner(System.in); int n; while (cin.hasNextInt()) { n = cin.nextInt(); if (n <= 4) { ... 阅读全文
posted @ 2012-04-05 22:00 Try86 阅读(220) 评论(0) 推荐(0)
摘要: //模拟#include <cstdio>#include <iostream>using namespace std;void swap(char &a, char &b) { char temp = a; a = b; b = temp;}int main() { int t, i; scanf ("%d", &t); while (t--) { int n, x, y; char s[9] = {"#ZJUTACM"}; scanf ("%d", &n); for (i=0 阅读全文
posted @ 2012-04-05 21:40 Try86 阅读(156) 评论(0) 推荐(0)
摘要: 设多重集的个数n = n1 + n2 + ... + nk;则该多重集的排列个数为:n!/(n1!n2!...nk!).//组合数+java大数import java.util.Scanner;import java.math.BigInteger;public class hdu1261{ public static void main(String args[]) { Scanner cin = new Scanner(System.in); BigInteger f1, f2; int []s = new int[26]; int n, sum; n = cin.nextIn... 阅读全文
posted @ 2012-04-05 21:04 Try86 阅读(402) 评论(0) 推荐(0)
摘要: //递推,f(i) = f(i-1) + 6 * (i-1); f[1] = 2, i>=2;#include <cstdio>#include <iostream>using namespace std;int f[10001];int main() { int i; f[1] = 2; for (i=2; i<10001; ++i) f[i] = f[i-1] + 6 * (i - 1); int t; scanf ("%d", &t); while (t--) { int n; scanf ("%d", 阅读全文
posted @ 2012-04-05 18:30 Try86 阅读(257) 评论(0) 推荐(0)
摘要: 实现自Matrix67!//二进制逆序//分治思想//程序读入一个32位整数并输出它的二进制倒序后所表示的数#include <stdio.h>int main() { int n; while (scanf("%d", &n) != EOF) { n = (n & 0x55555555) << 1 | (n & 0xAAAAAAAA) >> 1; n = (n & 0x33333333) << 2 | (n & 0xCCCCCCCC) >> 2; n = (n & 阅读全文
posted @ 2012-04-05 12:53 Try86 阅读(395) 评论(0) 推荐(0)
摘要: //用异或运算交换两个整数#include <stdio.h>int main() { int a, b; while (scanf("%d%d", &a, &b) != EOF) { a = a ^ b; b = a ^ b; a = a ^ b; printf ("%d %d\n", a, b); } return 0;}//用位运算来取绝对值#include <stdio.h>int main() { int n; while (scanf("%d", &n) != EOF) { 阅读全文
posted @ 2012-04-05 12:25 Try86 阅读(160) 评论(0) 推荐(0)
上一页 1 ··· 7 8 9 10 11 12 13 14 下一页