POJ 1002 487-3279 字符串处理
#include <iostream>#include <string>#include <algorithm>#include <cstdio>const int maxn = 20000;const int MAXN = 100000+10;using std :: string;using std :: cout;using std ::...
View ArticlePOJ 1004 Financial Management
#include <iostream>#include <cstdio>using std :: cin;using std :: cout;using std :: endl;int main(){ double ans; double tmp; ans = 0; for( int i = 0; i < 12; i++ ) {...
View ArticlePOJ 1005 I Think I Need a Houseboat
/**//******************************************设需要n年设半圆面积为 S,半径为 rS = 50 * n;S = (PI * r * r) / 2;解得 n = (PI * r * r ) / 100;所给点到原点距离 len = sqrt( x * x + y * y );令len = r即可解出...
View ArticlePOJ 1006 Biorhythms 中国剩余定理
/**//***************************************比较经典的中国剩余定理~~使33×28被23除余1,用33×28×6=5544使23×33被28除余1,用23×33×19=14421使23×28被33除余1,用23×28×2=1288(5544×p+14421×e+1288×i)%(23×28×33)=n+dn=(5544×p+14421×e+1288×i-d...
View ArticlePOJ 1007 DNA Sorting 字符串处理|稳定排序
/**//*****************字符串处理稳定排序******************/#include <iostream>#include <algorithm>#include <string>using namespace std;struct DNA{ int pos; int cnt; string str;};bool...
View ArticleHDU 1097 A hard puzzle
//找规律,每4个数循环一次#include <iostream>#include <cstdio>using namespace std;int main(){ long long a, b; int ans[5]; while(cin >> a >> b) { if( b == 0 ) {...
View ArticleHDU 3661 Assignments-2010 Harbin Regional
Assignments Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 252 Accepted Submission(s): 125 Problem Description In a factory, there are N...
View ArticleHDU 2734 Quicksum 简单字符串处理
Quicksum Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 492 Accepted Submission(s): 408 Problem Description A checksum is an algorithm that...
View ArticlePOJ 1269 Intersecting Lines 判断直线相交并求交点
Intersecting Lines Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 4260 Accepted: 2049 Description We all know that a pair of distinct points on a plane defines a line and that a pair of...
View ArticlePOJ 2653 Pick-up sticks 判断线段相交
Pick-up sticks Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 4189 Accepted: 1501 Description Stan has n sticks of various length. He throws them one at a time on the floor in a random way....
View ArticleHDU 1010 Tempter of the Bone
#include <iostream>#include <cstdio>#include <cmath>const int maxn = 10;using namespace std;bool escape;char map[maxn][maxn];int dir[4][2] = {{-1,0}, {1,0}, {0,-1}, {0,1}};int n, m,...
View ArticleHDU 1198 Farm Irrigation
#include<iostream>using namespace std;int bin[2500];int find(int x){return x==bin[x]?x:find(bin[x]);}void merge(int x,int y){ x=find(x); y=find(y); if(x!=y) bin[x]=y;}int main(){ int...
View ArticlePOJ 1611 The Suspects
#include <iostream>#include <cstdio>const int maxn = 30000 + 5;using namespace std;int father[maxn],rank[maxn];void init( int n ){ for ( int i = 0; i < n; i++) { father[i] =...
View ArticlePOJ 3264 Balanced Lineup
#include <iostream>#include <cstdio>#include <algorithm>const int MY_MAX = -99999999;const int MY_MIN = 99999999;using namespace std;struct CNode{ int R, L; int nMax, nMin;...
View ArticlePOJ 3468 A Simple Problem with Integers
#include <iostream>#include <cstdio>using namespace std;struct CNode{ int L, R; CNode * pLeft, * pRight; long long nSum, Inc;};CNode Tree[1000000];int nCount = 0;void BuildTree(...
View ArticlePOJ 2488 A Knight's Journey ----- DFS
#include <stdio.h>#include <string.h>const int maxn = 50;int b[8]={-2, -2, -1, -1, 1, 1, 2, 2},a[8]={-1, 1, -2, 2, -2, 2, -1, 1};bool check[maxn][maxn], flag;int ansx[maxn], ansy[maxn];int...
View ArticleHDU 1316 How Many Fibs?
比较水的大数。。。代码: import java.util.*;import java.math.*;public class Main{ public static void main( String args[] ) { Scanner in = new Scanner( System.in ); int cnt = 0;...
View Article求两个或N个数的最大公约数(gcd)和最小公倍数(lcm)的较优算法
求两个或N个数的最大公约数(gcd)和最小公倍数(lcm)的较优算法 //两个数的最大公约数--欧几里得算法int gcd(int a, int b){ if (a < b) swap(a, b); if (b == 0) return a; else return gcd(b,...
View ArticleHDU 1018 Big Number
斯特灵公式是一条用来取n阶乘近似值的数学公式。一般来说,当n很大的时候,n阶乘的计算量十分大,所以斯特灵公式十分好用,而且,即使在 n很小的时候,斯特灵公式的取值已经十分准确。 公式为: 这就是说,对于足够大的整数n,这两个数互为近似值。更加精确地: 或者: Big Number Time Limit: 20000/10000 MS (Java/Others) Memory...
View Article组合数学常用公式及算法
摘要: /**//**********************************************1. C(m,n)=C(m,m-n)2. C(m,n)=C(m-1,n)+C(m-1,n-1)derangement D(n) = n!(1 - 1/1! + 1/2! - 1/3!&nb... 阅读全文Vontroy 2010-10-02 14:25 发表评论
View Article