自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(27)
  • 收藏
  • 关注

原创 HDU 5317

#include#include#includeusing namespace std;const int maxn = 1e6 + 131;bool Jug[maxn];int Pos[maxn];int Num[maxn][10];//NUm[i][j] 表示 到 i F(i) 为 j 的个数 void Make() { for(int i = 2; i <= maxn

2015-07-28 15:34:59 433

转载 LightOJ 1336

http://blog.csdn.net/lxpaopao/article/details/45417517只能说神代码,666666,佩服!!

2015-05-24 20:50:24 443

原创 SGU 106

扩展欧几里得的应用但是精度确实是被卡成Dog#include#include#includeusing namespace std;typedef __int64 LL;LL gcd(LL a,LL b){return b==0?a:gcd(b,a%b);}void gcdex(LL a, LL b, LL &d, LL &x, LL &y) { if(!b) d = a,

2015-05-23 20:45:29 350

原创 Light Oj 1236

题意:求1-n有多少对数的LCM正好为 n先求 N 的标准分解试p1 ^ a1   *  p2 ^ a2 .......... pk ^ ak;有LCM 的可知 (a, b) 中必必有一个 含有 pi ^ ai;另一个则是 pi ^ 0  . . ......  pi ^ ai;所以一共有  NUM  =    II  (ai +1 ) * 2 - 1又因为 对

2015-05-20 20:31:28 322

原创 LightOJ 1259

题意:求一个偶数有多少个二元组质数相加正好等于其本身 哥德巴赫猜想0.0卡了空间,筛选质数用 bool 数组 0.0#include#include#include#include#include#include#include#include#include#define lson l , m, rt << 1#define rson m+1, r, rt << 1|

2015-05-19 21:14:13 379

原创 LightOJ 1282

题意 :求 n 的 k 次方的 前 3位数 和 后三位数;后三位直接 快速幂去摸;前三位:( n^ k / 10^ ? )可以 直接   Lg(n) * k - int (Lg(n) * k )得出的是   N ^ K的除 10 ^ y后的小数  对 10 取对数的结果   ans;这时候反过来 pow (10, ans )  得到这个数再 * 100 解决了#in

2015-05-19 20:39:33 330

原创 LightOJ 1341

题意 :一个数可以表示 N 对 数相乘(x1,x2)输入另一个数b  求有多少对x1 x2 俊大于等于 b求标准分解式的指数  因子数为 II(ai + 1)(表示不出数学符号.............)代码:#include#include#include#includeusing namespace std;typedef long long LL;co

2015-05-19 19:17:43 321

原创 字集打印0.0

#include#includeusing namespace std; const int maxn = 100;int Num[maxn];int tmp[maxn];void Subset_1(int n,int *A,int cur) { ///可以按照排列的类似写法撸出随意集合的字集0.0 for(int i = 0; i < cur; ++i) cout << A[i

2015-05-13 20:18:29 241

原创 排列模板0.0

#include#includeusing namespace std;const int maxn = 100;int Num[maxn];int tmp[maxn];void Printf(int n,int *A,int cur) { if(cur == n) { for(int i = 0; i < n; ++i) cout << A[i]; cout << endl

2015-05-13 19:56:54 215

原创 Uva 11181

题意:有n个人去超市买东西Pi 为 i 买东西的概率逛完后 得知有 r 人买了东西输出每人买东西的概率有R 人买了东西的事件为 E , 第 I 人买了东西的 事件为 Ai题目求的是 P(Ai | E ) = P ( Ai E ) / P(E)P(E)即为 正好有r 人买了东西的概率和而 一组r 人买了东西概率 为 Bi 第 i 人买了东西的 概率为  B

2015-05-12 21:46:00 255

原创 UVA 10491

题意:门里面放牛或者车有a 头牛, b两车;有人帮你开了c 个有牛的门求概率0.0分情况:你选的是车还是不是车的情况#include#includeusing namespace std;int main() { double a,b,c; while(cin >> a >> b >> c ) { printf("%.5lf\n",(a*b+b*(

2015-05-12 20:42:22 305

原创 Uva 1636

题意:第一枪开出去没有子弹要使后一枪木有子弹,怎么操作0.0所以两枪木有子弹是 00子串还有随机转一下, 转完后是0的概率为 NUM(0) / NUM(len )所以就是比NUM(00) / 【NUM(00) + NUM(01)】 和 NUM (0) / NUM(len)的大小0.0#include#include#includeusing namespace std

2015-05-12 20:17:38 313

原创 Uva 10820

就是求有多少组(x,y) 二元组 x ,y 互质先x 《 y 再 y 《 x 0.0phi(1-n)0.0:#includeusing namespace std;typedef long long LL;const int maxn = 50000 + 131;LL PHI[maxn];void Phi(int n,LL *phi) { for(int i = 2

2015-05-11 22:18:01 318

原创 Uva 1635

题意:大概就是输出C(n,k)不能整除 m看来LRJ 的解析,开始不知道输出方式0.0一直WA ,还以为哪里爆了int,结果.............可以优化0.0代码:#include#include#include#include#includeusing namespace std;typedef unsigned long long UL

2015-05-11 20:20:23 320

原创 Uva 12716

题意:输入N , 求有多少对(a,b) gcd(a,b) == a ^ b然而  gcd(a,b) == a ^ b = c 可以得出 b = a - c;然后就是枚举c  a 了#include#include#include#includeusing namespace std;const int maxn = 30000000 +131;typedef long

2015-05-07 20:47:09 255

原创 Uva 10791

题意:输入N,求至少两个数 使其lcm值为 N#include#includeusing namespace std;typedef long long LL;const LL INF = 0x7fffffff;const int M = sqrt(INF + 0.5);LL P[M];int count;void Get(LL n) {count =

2015-05-07 19:41:27 312

原创 Uva 10375

题意:求解C(m,n) / C(r,s) 利用每个数的唯一分解试,然后用一个辅助数组写出素数的指数最后在统一计算(开始手打快速幂,发现我SB,会出现负数)#include#include#include#includeusing namespace std;const int maxn = 5000;int num[maxn<<2],primes[maxn],e[m

2015-05-06 22:27:53 293

转载 Uva 12169

http://blog.csdn.net/u013451221/article/details/38497029感谢原博主提供的思想。带扩展二字的算法都可以出奇迹啊!#includeusing namespace std;typedef unsigned long long LL;LL num[300];void Gcd(LL a,LL b,LL &gcd,LL &x,LL &

2015-05-06 21:24:29 441

原创 UVA 11582

二元组有循环节,找出循环,在快速幂求出第几个,输出即可, (LL 大法好)#include#includeusing namespace std;typedef unsigned long long LL;const int maxn = 1000 + 5;int M[maxn];int F[maxn][maxn<<2];int pow_mod(LL a,LL b,int mod)

2015-05-06 20:12:09 305

原创 POJ 1160 DP

题意是一条线,有N 个村庄 , 建立 M 个邮局 , 求所有村庄到邮局的距离最短。在处理Long 和DP 时记得防止超int 范围.........#include#include#include#include#includeusing namespace std;typedef unsigned long long LL;const int maxn = 331;con

2015-04-29 21:14:34 229

原创 UVA 11464 例题7

算个水题吧,但是技巧很多。像这种状态类似 0  1 的 可以尝试着用2进制来表示。贴个代码#include#include#include#includeusing namespace std;const int INF = 0x7fffffff;int n,A[20][20],B[20][20];int Check(int s) { //s

2015-04-28 20:42:00 416

原创 大白鼠第一章例题6

World Final La 2995点击打开链接题目感觉不难,模拟提,思路有点绕,照着刘汝佳大大的代码打了一遍,虽然不难,但是学到了很多技巧!#include#include#include#include#include#define Loop(i,n) for(int i = 0; i < (n); ++i)using namespace std;int

2015-04-28 19:46:29 266

原创 KMP + AC + 后缀

这几天学习了有关字符串的算法:贴几个模板KMP :void GetNext(string &a){ memset(next,0,sizeof(next)); int len = a.length(); int j,i; next[0] = -1; j = -1;i = 0; while(i < len) { if(j == -1 || a[j] == a[i])

2015-04-27 19:20:52 329

原创 POJ 2774

点击打开链接 题目链接可以用hash 和后缀数组两种方法。(用hash 的话标记hash 要自己手打hash_map,stl超时了)#include#include#include#include#includeusing namespace std;typedef unsigned long long LL;const int maxn = 100000 + 23;c

2015-04-27 19:14:47 248

转载 Uva 201

转自点击打开链接感谢博主代码!#include #include #include #include #include #include using namespace std;int H[10][10];int V[10][10];int main(){ int n,m,x,y,T = 0; char c; while (~scanf("%d%d

2015-03-15 19:47:30 288

转载 POJ3083

http://sfiction.blog.163.com/blog/static/19940401020124355831319/  感谢作者的思路拯救了我DescriptionThe cornfield maze is a popular Halloween treat. Visitors are shown the entrance and must w

2014-12-08 20:57:13 410

原创 POJ 2488 DFS

DescriptionBackgroundThe knight is getting bored of seeing the same black and white squares again and again and has decided to make a journey around the world. Whenever a knight moves, it is

2014-12-08 18:44:26 500

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除