题目链接:http://codeforces.com/problemset/problem/589/F A gourmet came into the banquet hall, where the cooks suggested n dishes for guests. The gourmet knows the schedule: when each of the dishes will be served. For i-th of the dishes he knows two integ…
贪心 考场上因无优化与卡常T掉的\(n \log(n)\) //#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> #define R(a,b,c) for(register int a = (b); a <= (c); ++ a) #define nR(a,b,c) for(register int a…
F. Gourmet and Banquet time limit per test 2 seconds memory limit per test 512 megabytes input standard input output standard output A gourmet came into the banquet hall, where the cooks suggested n dishes for guests. The gourmet knows the schedule:…
BZOJ3527 推出卷积公式FFT求值 传送门:https://www.lydsy.com/JudgeOnline/problem.php?id=3527 题意: \(F_{j}=\sum_{i<j} \frac{q_{i} q_{j}}{(i-j)^{2}}-\sum_{i>j} \frac{q_{i} q_{j}}{(i-j)^{2}}\) 求\(E_i=F_i/q_i\) 题解: 推公式: \[ E_i=F_i/q_i\\ E_i=\sum_{j=i}^{n}\frac{q_j}{(i…
http://acm.hdu.edu.cn/showproblem.php?pid=3641 学到: 1.二分求符合条件的最小值 /*==================================================== 二分查找符合条件的最小值 ======================================================*/ ll solve() { __int64 low = 0, high = INF, mid ; while(low <=…
题目地址:http://ac.jobdu.com/problem.php?pid=1085 题目描述: N<k时,root(N,k) = N,否则,root(N,k) = root(N',k).N'为N的k进制表示的各位数字之和.输入x,y,k,输出root(x^y,k)的值 (这里^为乘方,不是异或),2=<k<=16,0<x,y<2000000000,有一半的测试点里 x^y 会溢出int的范围(>=2000000000) 输入: 每组测试数据包括一行,x(0<…
解题的思路很巧,为了让每个数之间都留出对应的上升空间,使a[i]=a[i]-i,然后再求LIS 另外二分求LIS是比较快的 #include<bits/stdc++.h> #define maxn 1000005 #define ll long long using namespace std; int len,n,a[maxn],lis[maxn]; int main(){ int t; scanf("%d",&t); ;tt<=t;tt++){ scanf…
二分求幂 int getMi(int a,int b) { ; ) { //当二进制位k位为1时,需要累乘a的2^k次方,然后用ans保存 == ) { ans *= a; } a *= a; b /= ; } return ans; } 快速幂取模运算 公式: 最终版算法: int PowerMod(int a, int b, int c) { ; a = a % c; ) { = = )ans = (ans * a) % c; b = b/; a = (a * a) % c; } retur…
一个引子 如何求得a的b次幂呢,那还不简单,一个for循环就可以实现! void main(void) { int a, b; ; cin >> a >> b; ; i <= b; i++) { ans *= a; } cout << ans; } 那么如何快速的求得a的b次幂呢?上面的代码还可以优化吗? 当然是ok的!下面就介绍一种方法-二分求幂. 二分求幂 所谓二分求幂,即是将b次幂用二进制表示,当二进制位k位为1时,需要累乘a的2^k次方. 下面优化一下上面…
郁闷的C小加(三) 时间限制:1000 ms  |  内存限制:65535 KB 难度:4   描述 聪明的你帮助C小加解决了中缀表达式到后缀表达式的转换(详情请参考“郁闷的C小加(一)”),C小加很高兴.但C小加是个爱思考的人,他又想通过这种方法计算一个表达式的值.即先把表达式转换为前缀和后缀表达式,再求值.这时又要考虑操作数是小数和多位数的情况.   输入 第一行输入一个整数T,共有T组测试数据(T<10).每组测试数据只有一行,是一个长度不超过1000的字符串,表示这个运算式,每个运算式都…