随笔分类 -  数学题

随机化算法
摘要:无比膜拜这个犀利的随机化算法#include <algorithm>#include <cstdio>#include <cstdlib>#define MAX 300000#define ITER 100using namespace std;typedef pair<int,int> par;inline int myrand() { int a = rand()%5000; int b = rand()%5000; return a*5000+b;}int n, Q, C;int a[MAX];par b[MAX];int main( vo 阅读全文

posted @ 2012-10-05 21:00 more think, more gains 阅读(185) 评论(0) 推荐(0)

HDU 4407 sum 容斥原理
摘要:算法:利用数据1...N的性质,求与P的互质的个数,位运算,容斥定理。。#include<stdio.h>#include<stdlib.h>#include<string.h>#include<iostream>#include<vector>#include<string>#include<math.h>#include<map>#include<set>#include<algorithm>using namespace std;struct info{ int s,e 阅读全文

posted @ 2012-09-22 21:07 more think, more gains 阅读(339) 评论(0) 推荐(0)

hdu 1018
摘要:Big NumberTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 11217Accepted Submission(s): 5051Problem DescriptionIn many applications very large integers numbers are required. Some of these applications are using keys for secure transmission of data, 阅读全文

posted @ 2011-08-26 00:33 more think, more gains 阅读(175) 评论(0) 推荐(0)

Calculate S(n) hdu 2114
摘要:Calculate S(n)Time Limit: 10000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3451Accepted Submission(s): 1335Problem DescriptionCalculate S(n).S(n)=13+23 +33 +......+n3 .InputEach line will contain one integer N(1 < n < 1000000000). Process to end of file. 阅读全文

posted @ 2011-08-16 21:54 more think, more gains 阅读(268) 评论(0) 推荐(0)

hide handkerchief hdu 2104
摘要:hide handkerchiefTime Limit: 10000/3000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1107Accepted Submission(s): 530Problem DescriptionThe Children’s Day has passed for some days .Has you remembered something happened at your childhood? I remembered I often played a 阅读全文

posted @ 2011-08-16 21:19 more think, more gains 阅读(364) 评论(0) 推荐(0)

Math one poj 3372 contest4
摘要:#include <iostream> #include <cstdio> using namespace std; int main() { int n; while(scanf("%d", &n)!= EOF) { if (!(n&(n-1))) { printf("YES\n"); } else printf("NO\n"); } } 证明:http://www.cnblogs.com/Saatgut/archive/2008/10/09/1307405.html 阅读全文

posted @ 2011-08-04 07:21 more think, more gains 阅读(174) 评论(0) 推荐(0)

平方数 contest 4
摘要:1565: 平方数Time Limit: 1 SecMemory Limit: 128 MBSubmit: 22Solved: 13[Submit][Status][Web Board]Description定义一类整数叫K-Omitted-Square-Number(K-OSN),如果数N是K-OSN必须满足下列条件:(1) 它是一个完全平方数。(2) 它的最末一位不为零。(3) 它不小于10的K次方。(4) 它的最后K位被截去后,所得的结果仍旧是一个完全平方数。现在给你一个正偶数K,求它的最大K-OSN。Input有多个案例。第一行为T(T<=20),是案例数,每个案例(一行)都只有 阅读全文

posted @ 2011-08-04 00:16 more think, more gains 阅读(213) 评论(0) 推荐(0)

Intersecting Lines
摘要:Intersecting LinesTime Limit: 1000MSMemory Limit: 10000KTotal Submissions: 5339Accepted: 2526DescriptionWe all know that a pair of distinct points on a plane defines a line and that a pair of lines on a plane will intersect in one of three ways: 1) no intersection because they are parallel, 2) inter 阅读全文

posted @ 2011-08-02 22:19 more think, more gains 阅读(375) 评论(0) 推荐(0)

排列2 pe了好几次。。悲剧
摘要:#include <stdio.h>#include <string.h>#include <stdlib.h>#include <algorithm>using namespace std;int main( ){ char str[10], ch[10]; int len, flag, a[10], i, flag1, k = 0; while (1) { flag1 = 0; for ( i = 0; i < 4; i++) scanf("%d",&a[i]), str[i] = a[i] + '0 阅读全文

posted @ 2011-07-28 10:09 more think, more gains 阅读(175) 评论(0) 推荐(0)

AC
摘要:A CTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1741Accepted Submission(s): 1089Problem DescriptionAre you excited when you see the title "AC" ? If the answer is YES , AC it ;You must learn these two combination formulas in the school 阅读全文

posted @ 2011-07-28 09:16 more think, more gains 阅读(188) 评论(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 阅读(205) 评论(0) 推荐(0)

The area 积分
摘要:思路就是用顶点式求抛物线的方程,然后再再求出其原函数,积分减去梯形面积即可 1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <math.h> 4 5 double a, b, c, x1, x2, x3, p1, p2, p3; 6 7 double fun (double x ) 8 { 9 return (1.0 / 3 ) * a * ( x - x1 ) * (x - x1 ) * (x - x1 ) + p1 * x; 10 }11 12 int main( )13 {14 int T, 阅读全文

posted @ 2011-07-20 10:29 more think, more gains 阅读(240) 评论(0) 推荐(0)

数论学习之最大公约数与最小公倍数
摘要:数论学习之最大公约数与最小公倍数最大公约数 定义:设a,b是两个整数,如果d|a,且d|b,则称d是a和b的公因子,或公约数,除0之外,任和整数只有有限个因子,其中最大的叫做最大公约数。 记做: gcd( a, b)最小公倍数 定义:设a, b 是两个整数,如果a|d,b|d,则称d是a,b的公倍数,a,b的公倍数有无穷个,最小的那个称做最小公倍数。 记做 :lcm (a,b); 显然对于任意的正整数a:gcd(0,a) = a; gcd(1,a)=1; lcm(1,a) = a;最小公倍数与最大公约的数两条性质:1.a|m , b|m, lcm(a,b) l m;2.m|a,m|b, m | 阅读全文

posted @ 2011-07-20 09:44 more think, more gains 阅读(595) 评论(0) 推荐(0)

easy problem
摘要:数学题,求因子。。(i+1)(j+1)=N+1 #include<stdio.h>#include<math.h>int main(){ int N,i,n,j; __int64 M; scanf("%d",&N); while(N--) { n=0; scanf("%I64d",&M); M++; j=sqrt(M*1.0); for(i=2;i<=j;i++) if(M%i==0) n++; ... 阅读全文

posted @ 2011-05-02 09:53 more think, more gains 阅读(220) 评论(0) 推荐(0)

整数解
摘要:#include<stdio.h>#include<math.h>int main( ){ int a,b,t; while(scanf("%d%d",&a,&b),a|b){ t=sqrt(a*a-4*b); printf(a*a-4*b>=0&&(a*a-4*b-t*t==0)?"YES\n":"NO\n"); }return 0;}数学题。。 阅读全文

posted @ 2011-05-01 09:25 more think, more gains 阅读(242) 评论(0) 推荐(0)

导航