擦,没啥好说的,这个模板至少得打10遍。。纪念自己成功的打错了。。
#include
#include
#include
#include
using namespace std;
#define LL int
#define lson id << 1
#define rson id << 1|1
const LL M = 100008;
LL ti[M],top[M],siz[M],...
分类:
其他好文 时间:
2014-10-07 10:40:53
阅读次数:
260
原文地址:
对于一般的求a^b%c的值,当a,b都在long long范围内,c在1e9的时候,都可以用快速幂取模进行求解。
LL powerMod(LL x, LL k, LL m){
LL res = 1;
while(x %= m, k){
if(k&1) res *= x, res %= m;
x *= x, k...
分类:
其他好文 时间:
2014-08-16 17:08:50
阅读次数:
291
题意:对一串数字进行抑或某数,和某数,或某数,统计某区间和的操作。思路:因为化成二进制就4位可以建4颗线段树,每颗代表一位二进制。and 如果该为是1 直接无视,是0则成段赋值为0;or 如果是0 无视,是1则成段赋值为1;xor 成段亦或,1个数和0个数交换;sum 求和;#include#inc...
分类:
其他好文 时间:
2014-07-31 02:22:55
阅读次数:
258
C - 纪念SlingShot Description 已知 F(n)=3 * F(n-1)+2 * F(n-2)+7 * F(n-3),n>=3,其中F(0)=1,F(1)=3,F(2)=5,对于给定的每个n,输出F(0)+ F(1)+ …… + F(n) mod 2009。 Input 第一行是...
分类:
其他好文 时间:
2014-07-29 21:00:52
阅读次数:
224
水题,不过要想0ms过还是有个技巧的:#include #include using
namespace std;int main(){ int score[101]; int t,t1,temp; while(cin>>t) {
//memset(score,...
分类:
其他好文 时间:
2014-05-30 16:53:11
阅读次数:
268
题目来源:http://acm.fzu.edu.cn/problem.php?pid=1016分析:图画如下:我们可以 列出方程。1 ) x * cos(a)
+ y * sin(a) = A2 ) x * sin(a ) + y * cos(a) = B对方程 化简为2 = (a + b)...
分类:
其他好文 时间:
2014-05-04 20:54:26
阅读次数:
371
题目来源:FOJ 2170 花生的序列
题意:给你一个长度为2*n的由W和B组成字符串 该字符串是由2个长度为n的并且是WBWBW....形式的 求有多少种组成方案
思路:dp[i][j] 代表第一个字符串长度为i 第二个字符串长度为j时的数量然后根据i和j的奇偶数递推
i为奇数 原来的字符串的第i位是W 为偶数是B
j同上
i+j是到输入的串的位置
#include
#inc...
分类:
其他好文 时间:
2014-04-29 13:34:20
阅读次数:
286
题目链接:http://acm.fzu.edu.cn/problem.php?pid=2173
思路:
类似于传递闭包的性质
用矩阵mp[i][j] 表示i点到j点 走1次的最短路
--------------
若我们用 mp[i][j] 表示从i点到j点 走了k次的最短路距离
那么我们要通过 矩阵mp 得到 矩阵 ret[u][v] 表示 u->v 走了2*k次的最短路
就...
分类:
其他好文 时间:
2014-04-29 13:24:20
阅读次数:
386
题目链接:http://acm.fzu.edu.cn/problem.php?pid=2170
贴个baka爷的代码留念。。
数据出的有问题,输入的字符串长度不超过1000
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define inf 0x3f3f3f...
分类:
其他好文 时间:
2014-04-27 22:16:18
阅读次数:
359
题目链接:http://acm.fzu.edu.cn/problem.php?pid=2171
题意:
给定n长序列,常数m,q个询问
对于每个询问x
1、求[x, x+m-1] 区间和
2、[x,x+m-1]区间的所有元素-1
线段树裸题,不知为何全用longlong会re,只能改成部分longlong
#include
#include
#define ll long long
...
分类:
其他好文 时间:
2014-04-27 21:35:00
阅读次数:
328