随笔分类 -  数学

poj 2513 Colored Sticks
摘要:http://poj.org/problem?id=2513和离散数学有关 欧拉回路问题同一颜色的标记为同一点 同一stick 的两端为相连状态数学什么的 最不擅长了 看了别人的解析两个限制条件1 图为联通 可用并查集判断2 度 (出度+入度)数为基数的点为0 或者为 2 输入时相加不满足上述两个条件中的任何一个 都Impossible存颜色和查询要用字典树 用map超时代码及其注释:#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>#include< 阅读全文
posted @ 2012-08-11 17:57 夜-> 阅读(119) 评论(0) 推荐(0)
poj 1095 Trees Made to Order
摘要:http://poj.org/problem?id=1095先打个表 然后dfs一下#include<iostream>#include<cstdio>#include<cstdlib>#include<ctime>#include<queue>#include<cstring>#include<set>#include<cmath>#include<algorithm>#define LL long longusing namespace std;const int N=25;int 阅读全文
posted @ 2012-07-31 08:26 夜-> 阅读(167) 评论(0) 推荐(0)
poj 3286 How many 0's
摘要:http://poj.org/problem?id=3286#include<iostream>#include<cstdio>#include<cstdlib>#include<ctime>#include<queue>#include<cstring>#include<set>#include<cmath>#include<algorithm>#define LL long longusing namespace std;LL Fsum(LL x){ if(x==-1) return 阅读全文
posted @ 2012-07-30 16:59 夜-> 阅读(134) 评论(0) 推荐(0)
poj 2454 Jersey Politics
摘要:http://poj.org/problem?id=2454随机化 先从大到小排序 最后k个舍去把前2×k个分成两组然后不断交换两组的第随机产生个 元素知道满足条件#include<iostream>#include<cstdio>#include<cstdlib>#include<ctime>#include<queue>#include<cstring>#include<set>#include<cmath>#include<algorithm>using namespac 阅读全文
posted @ 2012-07-30 15:01 夜-> 阅读(252) 评论(0) 推荐(0)
poj 3318 Matrix Multiplication
摘要:http://poj.org/problem?id=3318g++ re c++ ac受不了了随机找了60000 个点比较的 运气好就过了#include<iostream>#include<cstdio>#include<cstdlib>#include<ctime>#include<queue>#include<cstring>#include<set>#include<cmath>#include<algorithm>using namespace std;const int N= 阅读全文
posted @ 2012-07-30 14:07 夜-> 阅读(202) 评论(0) 推荐(0)
poj 3301 Texas Trip
摘要:http://poj.org/problem?id=3301都说这个题是三分题目 但它不是单峰吧 好怀疑 我根据网上的代码写的 连第二组数据都过不了 但交上去 0ms 过啦建议不要做这道题 如果有高手指点 那就跟好了#include<iostream>#include<cstdio>#include<queue>#include<cstring>#include<set>#include<cmath>#include<algorithm>using namespace std;const int N=1005; 阅读全文
posted @ 2012-07-30 10:44 夜-> 阅读(211) 评论(0) 推荐(0)
poj 3070 Fibonacci
摘要:http://poj.org/problem?id=3070有点水呀#include <iostream>#include <cstdio>#include <queue>#include <cstring>#include <set>using namespace std;const int N=3000;const int M=10000;int a1,a2,b1,b2;int A1,A2,B1,B2;void func1(){ int tempa1,tempa2; int tempb1,tempb2; tempa1=a1*A1+ 阅读全文
posted @ 2012-07-29 19:27 夜-> 阅读(146) 评论(0) 推荐(0)
poj 3150 Cellular Automaton
摘要:http://poj.org/problem?id=3150不擅长数学类的题呀网上很多此题的解题报告 都不错 但是没有注释推荐解题报告:http://www.cppblog.com/varg-vikernes/archive/2011/02/08/139804.html我的代码及其注释:#include<iostream>#include<cstring>#include<algorithm>#include<cstdio>#define LL long longusing namespace std;const int N=505;LL a[N 阅读全文
posted @ 2012-07-28 20:55 夜-> 阅读(200) 评论(0) 推荐(0)
poj 2976 Dropping tests
摘要:http://poj.org/problem?id=2976通过二分 不断的移动左右边界 知道满足精度#include<iostream>#include<cstring>#include<algorithm>#include<cstdio>#define LL long longusing namespace std;const double eps=1e-4;const int N=1005;double a[N];double b[N];double c[N];bool cmp(double x,double y){ return x> 阅读全文
posted @ 2012-07-28 15:37 夜-> 阅读(166) 评论(0) 推荐(0)
poj 2115 C Looooops
摘要:http://poj.org/problem?id=2115作为一个数论白痴 遇到数论题我就有一种想死的冲动经过一个上午的奋斗 最终有一个地方还是看不懂问世间数论何物,只叫我生不如死。#include<iostream>#include<cstring>#include<algorithm>#include<cstdio>#define LL long longusing namespace std;LL exgcd(LL a,LL b,LL *x,LL *y){ if(b==0) { *x=1; *y=0; return a; } ... 阅读全文
posted @ 2012-07-28 11:13 夜-> 阅读(157) 评论(0) 推荐(0)
poj 1061 青蛙的约会
摘要:http://poj.org/problem?id=1061#include<iostream>#include<cstdio>#include<algorithm>#include<cstring>#include<cmath>#include<map>#include<queue>#include<cmath>#define LL long longusing namespace std;LL gcd(LL x,LL y){ if(x%y==0) return y; return gcd(y,x 阅读全文
posted @ 2012-07-27 11:21 夜-> 阅读(156) 评论(0) 推荐(0)
poj 3440 Coin Toss
摘要:http://poj.org/problem?id=3440简单题目 但是由于忽视了int越界 贡献了一次wa#include<iostream>#include<cstdio>#include<algorithm>#include<cstring>#include<cmath>#include<map>#include<queue>#include<cmath>#define LL long longusing namespace std;const double PI=acos(-1.0);in 阅读全文
posted @ 2012-07-26 20:34 夜-> 阅读(194) 评论(0) 推荐(0)
poj 3071 Football
摘要:http://poj.org/problem?id=3071记忆化搜索代码及其注释:#include<iostream>#include<cstdio>#include<algorithm>#include<cstring>#include<cmath>#include<map>#include<cmath>#define LL long longusing namespace std;const int N=130;double win[N][N];//第几队 在第几次比赛中获胜的概率double beat[ 阅读全文
posted @ 2012-07-26 11:12 夜-> 阅读(160) 评论(0) 推荐(0)
poj 1222 EXTENDED LIGHTS OUT
摘要:http://poj.org/problem?id=1222高斯消元#include<iostream>#include<cstdio>#include<algorithm>#include<cstring>#include<map>#include<cmath>#define LL long longusing namespace std;const int N=35;int lx[4]={1,-1,0,0};int ly[4]={0,0,1,-1};int a[N][N];int ans[N];int n;void G 阅读全文
posted @ 2012-07-26 10:01 夜-> 阅读(161) 评论(0) 推荐(0)
poj 2947 Widget Factory
摘要:http://poj.org/problem?id=2947基础高斯消元 注意时刻模7#include<iostream>#include<cstdio>#include<algorithm>#include<cstring>#include<map>#include<cmath>#define LL long longusing namespace std;const int N=350;int a[N][N];int ans[N];int n,m;char s[9][5]={"","MON 阅读全文
posted @ 2012-07-25 19:10 夜-> 阅读(165) 评论(0) 推荐(0)
poj 1026 Chipher
摘要:http://poj.org/problem?id=1026找到每个循环 并记录循环里有多少个数对每个循环的字符进行移动 移动一次是一个循环 移动的次数 为循环里数的个数的余数代码:#include<iostream>#include<cstdio>#include<algorithm>#include<cstring>#include<map>#include<cmath>#define LL long longusing namespace std;const int N=205;int a[N];int num[N] 阅读全文
posted @ 2012-07-25 11:51 夜-> 阅读(194) 评论(0) 推荐(0)
poj 3270 Cow Sorting
摘要:http://poj.org/problem?id=3270给n头牛 让你把他们升序排序 每次交换两个牛 交换花费是两个牛值之和求最小花费黑书上有 P248 求循环每个循环进行判断 一个循环的花费有两种情况可能为最优1 用循环内最小的花费牛 和其他牛 进行交换2 或是用全局最小花费牛 先和本环内最小花费牛交换 然后一样 最后再交换回来就可以了代码及其注释:#include<iostream>#include<cstdio>#include<algorithm>#include<cstring>#include<map>#include 阅读全文
posted @ 2012-07-25 10:40 夜-> 阅读(164) 评论(0) 推荐(0)
poj 2409 Let it Bead
摘要:http://poj.org/problem?id=2409#include<iostream>#include<cstdio>#include<algorithm>#include<cstring>#include<map>#include<cmath>#define LL long longusing namespace std;int gcd(int a,int b){ if(a%b==0) return b; return gcd(b,a%b);}LL ploya(int n,int m){ if(n==0) re 阅读全文
posted @ 2012-07-25 09:57 夜-> 阅读(160) 评论(0) 推荐(0)
poj 1286 Necklace of Beads
摘要:http://poj.org/problem?id=1286polya burnside难了不会 会了不难#include<iostream>#include<cstdio>#include<algorithm>#include<cstring>#include<map>#include<cmath>#define LL long longusing namespace std;int gcd(int a,int b){ if(a%b==0) return b; return gcd(b,a%b);}LL ploya(in 阅读全文
posted @ 2012-07-25 09:38 夜-> 阅读(140) 评论(0) 推荐(0)
poj 3292 Semi-prime H-numbers
摘要:http://poj.org/problem?id=3292#include<iostream>#include<cstring>#include<string>#include<cstdio>using namespace std;const int N=1000001;int ans[N];void findans(){ memset(ans,0,sizeof(ans)); for(int i=5;i<N;i+=4) { for(int j=5;j<N;j+=4) { int temp=i*j; if... 阅读全文
posted @ 2012-05-04 20:34 夜-> 阅读(158) 评论(0) 推荐(0)