算法初级
文章平均质量分 70
yiluuuuu
这个作者很懒,什么都没留下…
展开
-
【组合数学】POJ_1850_Code
//POJ_1850//比如说求比358小的由1-9的数字组成的数(0不算)//而且后面一个数一定比前一个数大,//而且不能重复,//类似于这个意思,这题是字母,当做数字范围1-26就行//C(9,2)+C(9,1)+C(7,2)+C(8,2)+C(6,2)+...不想写了,应该没算错//358 的话百位相等时,十位只能>=4,要满足比前一位数大,//两位数和一位数 百位不相等时,如果选2原创 2016-08-18 19:34:44 · 499 阅读 · 0 评论 -
【模拟】POJ_2706_Connect
#include #include #include #include #include using namespace std;int Map[1010][1010],vis[1010],n,m;struct p{ int x,y;} a[310];int in(int i,int j)//判断是否在日字的范围内{ if((fabs(a[i].x-a[j]原创 2016-09-26 21:28:22 · 170 阅读 · 0 评论 -
【模拟】POJ_1027_The Same Game
我马克思无话可说。。有空列向左移动的时候出了点问题,死循环。。#include #include //#include #define INF 0x3f3f3f3f//using namespace std;int dx[]= {1,-1,0,0};int dy[]= {0,0,1,-1};char Map[15][25];int vis[15][25],cnt=0,a[1原创 2016-09-25 19:14:50 · 224 阅读 · 0 评论 -
【POJ 3371】Flesch Reading Ease
#include #include #define judgesentence (s[len-1]=='.'||s[len-1]=='?'||s[len-1]==':'||s[len-1]==';'||s[len-1]=='!')#define judgevowel (s[i]=='a'||s[i]=='e'||s[i]=='i'||s[i]=='o'||s[i]=='u'||s[i]=='原创 2016-09-25 14:56:20 · 1040 阅读 · 0 评论 -
【CF609C】 Load Balancing
TutorialDenote s — the sum of elements in array. If s is divisible by n then the balanced array consists of n elements . In this case the difference between maximal and minimal elements is 0原创 2016-09-20 21:35:58 · 271 阅读 · 0 评论 -
【POJ3393】Lucky and Good Months by Gregorian Calendar
这题太可怕了早已经放弃自己翻译,网上搜的题意定义:Goog month : 该月第一个工作日为星期一的月份Luckly month: 该月最后一个工作日为星期五的月份问: 给定一个Gregorian Calendar格里高公历的 时间闭区间(就是包括端点的年月了)【开始年、月】~【结束年、月】 在这个时间区间内,有多少个Goog month,有多少个Luckly m原创 2016-09-19 21:10:58 · 276 阅读 · 0 评论 -
【数论】POJ_1845_Sumdiv
萌妹子小优的博客http://blog.csdn.net/lyy289065406/article/details/6648539(1) 整数的唯一分解定理: 任意正整数都有且只有一种方式写出其素因子的乘积表达式。 A=(p1^k1)*(p2^k2)*(p3^k3)*....*(pn^kn) 其中pi均为素数(2) 约数和公式:原创 2016-08-25 20:18:43 · 171 阅读 · 0 评论 -
【数论】POJ_2115_C Looooops
http://blog.csdn.net/non_cease/article/details/7364092这篇博客写的炒!鸡!好!,喜翻~解题思路看这篇博客http://blog.csdn.net/lyy289065406/article/details/6648546好了,没我的什么事了~#include #include #define ll long long原创 2016-08-25 19:59:13 · 283 阅读 · 0 评论 -
【数论】POJ_2635_The Embarrassed Cryptographer
//POJ_2635#include #include #define N 1000100int p[1000100],top=0;int f(){ p[++top]=2; for(int i=3; i<=N; i+=2) { int flag=1; for(int j=1; p[j]*p[j]<=i; j++)原创 2016-08-19 21:56:20 · 155 阅读 · 0 评论 -
【组合数学】POJ_3252_Round Numbers
Discuss里复制的思路看完各家算法,尝试独立分析一下: 以sample为例子 [2,12]区间的RoundNumbers(简称RN)个数:Rn[2,12]=Rn[0,12]-Rn[0,1] 即:Rn[start,finish]=Rn[0,finish]-Rn[0,start-1] 所以关键是给定一个X,求出Rn[0,X] 现在假设X=10100100 这个X的二进制总共是原创 2016-08-19 11:14:26 · 248 阅读 · 0 评论 -
【线段树】
POJ_3468#include #include #include #include #define N 100000#define ll long longusing namespace std;ll a[N+10];struct node{ int l,r; ll sum,add; struct node *lchild,*rchild;};原创 2016-08-18 19:12:44 · 180 阅读 · 0 评论