摘要: 1.读入优化 inline int read() { int ans=0,f=1;char t=getchar(); while(t<'0'||t>'9') f=(t=='-'?-1:1),t=getchar(); while(t>='0'&&t<='9') ans=ans*10+t-'0',t=g 阅读全文
posted @ 2017-11-07 13:20 12fs 阅读(203) 评论(0) 推荐(0) 编辑
摘要: 基础:快速幂,矩阵乘法; 快速幂: #include<cstdio> #include<cstring> #define ll long long ll poww(ll a,ll b) { ll ans=1; while(b) { if(b&1) ans*=a; b>>=1;a*=a; } retu 阅读全文
posted @ 2017-11-05 22:00 12fs 阅读(200) 评论(0) 推荐(0) 编辑
摘要: 主要是51nod上的中位数(距离之和最小): 一:1096 距离之和最小: 是一道水题; #include<cstdio> #include<cstring> #include<algorithm> using std::sort; int map[10010]; int main() { int 阅读全文
posted @ 2017-11-05 21:39 12fs 阅读(376) 评论(0) 推荐(0) 编辑
摘要: 先来个模版:(P3375) #include<cstdio> #include<cstring> const int N=1000010; char a[N],b[N]; int lena,lenb,next[N]; void init() { int j=0;next[1]=0; for(int 阅读全文
posted @ 2017-11-05 21:18 12fs 阅读(145) 评论(0) 推荐(0) 编辑
摘要: 一:01背包 #include<cstdio> #include<algorithm> using namespace std; int m,t; int f[1001]; int w[1001],c[1001]; int main() { scanf("%d %d",&t,&m); for(int 阅读全文
posted @ 2017-10-28 15:59 12fs 阅读(230) 评论(0) 推荐(0) 编辑
摘要: 1174 区间中最大的数 基准时间限制:1 秒 空间限制:131072 KB 1174 区间中最大的数 基准时间限制:1 秒 空间限制:131072 KB 1174 区间中最大的数 基准时间限制:1 秒 空间限制:131072 KB 给出一个有N个数的序列,编号0 - N - 1。进行Q次查询,查询 阅读全文
posted @ 2017-10-28 15:39 12fs 阅读(203) 评论(0) 推荐(0) 编辑
摘要: 1105 第K大的数 基准时间限制:1 秒 空间限制:131072 KB 数组A和数组B,里面都有n个整数。数组C共有n^2个整数,分别是A[0] * B[0],A[0] * B[1] ......A[1] * B[0],A[1] * B[1]......A[n - 1] * B[n - 1](数组 阅读全文
posted @ 2017-10-27 21:47 12fs 阅读(297) 评论(0) 推荐(0) 编辑
摘要: 1589: [Usaco2008 Dec]Trick or Treat on the Farm 采集糖果 Description 每年万圣节,威斯康星的奶牛们都要打扮一番,出门在农场的N(1≤N≤100000)个牛棚里转悠,来采集糖果.她们每走到一个未曾经过的牛棚,就会采集这个棚里的1颗糖果. 农场 阅读全文
posted @ 2017-10-27 21:42 12fs 阅读(196) 评论(0) 推荐(1) 编辑
摘要: Description 在一个2维平面上有两条传送带,每一条传送带可以看成是一条线段。两条传送带分别为线段AB和线段CD。lxhgww在AB上的移动速度为P,在CD上的移动速度为Q,在平面上的移动速度R。现在lxhgww想从A点走到D点,他想知道最少需要走多长时间 Input 输入数据第一行是4个整 阅读全文
posted @ 2017-10-26 20:10 12fs 阅读(228) 评论(0) 推荐(0) 编辑
摘要: D - Decrementing Time limit : 2sec / Memory limit : 256MB Score : 1000 points Problem Statement There are N integers written on a blackboard. The i-th 阅读全文
posted @ 2017-10-24 19:22 12fs 阅读(227) 评论(0) 推荐(0) 编辑