2011年7月27日

SHLQSH数

摘要: 刚开始时用了算约数个数公式,果断超时。。#include <stdio.h>#include <string.h>#include <math.h>#include <stdlib.h>char prime[5000010]={0};int dp[700000];const int inf = 3500;int k, a, b, l;struct node {int v;int n;}val[1000];void fun( ){ int i, j; for ( i = 3; i <= inf; i += 2) if ( prime[i / 阅读全文

posted @ 2011-07-27 22:11 more think, more gains 阅读(229) 评论(0) 推荐(0)

组合 二项式定理

摘要: #include <stdio.h>#include <string.h>#include <stdlib.h>int c[1000];int c1[100][100];/* 排列与组合 c(n,k) = n ! / ( k! * (n - k)!)*//*1.求组合数利用等式2.利用杨辉三角*//*二项式定理(a + b) ^n = for k = 0 to nc(n,k) = a ^(n - k) * b ^k;*/ int main( ){ int i, j, n; while (scanf("%d", &n), n) { 阅读全文

posted @ 2011-07-27 20:58 more think, more gains 阅读(203) 评论(0) 推荐(0)

stl 全排列

摘要: #include <cstdio>#include <algorithm>#include <cstdlib>#include <string>#include <string.h>#include <iostream>using namespace std;//next_permutationint main( ){ int length, flag ; char str[1000]; while ( scanf("%s",str) != EOF ) { flag = 1; length = strl 阅读全文

posted @ 2011-07-27 20:16 more think, more gains 阅读(170) 评论(0) 推荐(0)

导航