HDU - 4686 函数积的前缀和】的更多相关文章

题意:求\(\sum_{i=0}^{n-1}a_ib_i\) 其中,\(a_i=A_xa_{i-1}+A_y,b_i=B_xb_{i-1}+B_y\) 构造矩阵分别维护\(a_ib_i,a_i,b_i,A_yB_y,A_y,B_y,S_i\) \[ \begin{bmatrix} a_ib_i \\ a_i \\ bi \\ A_yB_y \\ A_y \\ B_y \\ S_i\\ \end{bmatrix} = \begin{bmatrix} A_xB_x & A_xB_y & A_y…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6265 题目大意:首先T是测试组数,n代表当前这个数的因子的种类,然后接下来的p和q,代表当前这个数的因子中含有p的q次方.然后让你求题目第一行给你的信息. 首先理一下思路. 第一步,我们需要算题目中要求的公式(第一行),首先,他是一个积性函数,所以我们先将题目中的第一行的式子命名为F(n).对于F(n),我们可以分着求他的每一个因子的解,然后最终将这一写乘起来就可以了. F(n) = F(p1^q1…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4686 题意: 思路: #include <iostream>#include <cstdio>#include <string.h>#include <algorithm>#include <cmath>#include <vector>#include <queue>#include <set>#include…
Mophues 题意:给出n, m, p,求有多少对a, b满足gcd(a, b)的素因子个数<=p,(其中1<=a<=n, 1<=b<=m) 有Q组数据:(n, m, P <= 5×105. Q <=5000). 参考:ACdreamers 思路:对于hdu1695 GCD来说,由于只需要求gcd = k的个数,所以我们可以按照不优化莫比乌斯公式直接求,这样求解的时间复杂度为O(n); 若这题我们也不优化,答案累加需要双重循环: rep1(i,,n){ if(n…
题目:http://acm.hdu.edu.cn/showproblem.php?pid=4311 Meeting point-1 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3426    Accepted Submission(s): 1131 Problem Description It has been ten years s…
http://acm.hdu.edu.cn/showproblem.php?pid=6186 题意:给出n个数,共有n次询问,每次询问给出一个数p,求除去第p个数后的n-1个数的&.|.^值. 思路:分别计算出&.|.^的前缀和后缀,将前缀和后缀相计算即可. #include<iostream> #include<cstdio> #include<algorithm> using namespace std; ; int n, q; int a[maxn…
链接:http://acm.hdu.edu.cn/showproblem.php?pid=4686 题意: 其中a0 = A0ai = ai-1*AX+AYb0 = B0bi = bi-1*BX+BY 最后的结果mod 1,000,000,007 n<=10^18. 分析:ai*bi=(ai-1 *ax+ay)*(bi-1 *bx+by) =(ai-1 * bi-1 *ax*bx)+(ai-1 *ax*by)+(bi-1 *bx*ay)+(ay*by) 设p=ax*bx,  q=ax*by, …
http://acm.hdu.edu.cn/showproblem.php?pid=4686 当看到n为小于64位整数的数字时,就应该有个感觉,acm范畴内这应该是道矩阵快速幂 Ai,Bi的递推式题目已经给出, Ai*Bi=Ax*Bx*(Ai-1*Bi-1)+Ax*By*Ai-1+Bx*Ay*Bi-1+Ay*By AoD(n)=AoD(n-1)+AiBi 构造向量I{AoD(i-1),Ai*Bi,Ai,Bi,1} 初始向量为I0={0,A0*B0,A0,B0,1} 构造矩阵A{ 1,0,0,0,…
F - Detachment In a highly developed alien society, the habitats are almost infinite dimensional space. In the history of this planet,there is an old puzzle. You have a line segment with x units’ length representing one dimension.The line segment can…
Mathematically some problems look hard. But with the help of the computer, some problems can be easily solvable. In this problem, you will be given two integers a and b. You have to find the summation of the scores of the numbers froma to b (inclusiv…
给一个字符串S,求出所有前缀,使得这个前缀也正好是S的后缀.升序输出所有情况前缀的长度.KMP中的next[i]的意义就是:前面长度为i的子串的前缀和后缀的最大匹配长度.明白了next[i],那么这道题就很容易做了 #include <iostream> #include <stdio.h> #include <string.h> #include <algorithm> using namespace std; ; char str[maxn]; int…
Problem Description Clarke is a patient with multiple personality disorder. One day, Clarke split into two personality a and b, they are playing a game. There is a n∗m matrix, each grid of this matrix has a number ci,j. a wants to beat b every time,…
题目链接 \(Description\) 给定一张\(n\)个点\(m\)条边的无向图.定义割集\(E\)为去掉\(E\)后使得图不连通的边集.定义一个bond为一个极小割集(即bond中边的任意一个真子集都不是割集). 对每条边,求它在多少个bond中. \(n\leq20,\quad n-1\leq m\leq\frac{n(n-1)}{2}\). \(Solution\) https://www.cnblogs.com/zufezzt/p/5723389.html 首先bond是极小割集,…
Twin Prime Conjecture Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Problem Description If we define dn as: dn = pn+1-pn, where pi is the i-th prime. It is easy to see that d1 = 1 and dn=even for n>1. Twin Prime…
题意: 给你一串字符串,每个字符都有一个权值,要求把这个字符串在某点分开,使之成为两个单独的字符串 如果这两个子串某一个是回文串,则权值为那一个串所有的字符权值和 若不是回文串,则权值为0 解析: 先用Manacher算法求出以每个字母为中心的回文串的长度,并计算该字符串的前缀价值和.然后枚举切割点,得到两份子串.这样就可以知道每个子串的中心点,然后检查以该子串的中心点作为中心点的回文串的长度,如果长度等于该子串的长度,那么就加上该子串的价值.然后和最优价值比较就行了. 注意只有一个字符时输出0…
Olympiad Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Problem Description You are one of the competitors of the Olympiad in numbers. The problem of this year relates to beatiful numbers. One integer is called be…
Phone List Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 16223    Accepted Submission(s): 5456 Problem Description Given a list of phone numbers, determine if it is consistent in the sense tha…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4055 题意: 给你一个由'I', 'D', '?'组成的字符串,长度为n,代表了一个1~n+1的排列中(数字不重复),相邻数字的增长趋势.('I'为增,'D'为减,'?'为未知) 问你符合条件的数列有多少种. 题解: 表示状态: dp[i][j] = combinations 表示长度为i的排列(由1~i组成),末尾为j,这样的排列的个数 找出答案: ans = ∑ dp[n][1 to n] 如何…
点击加号查看代码 #include<bits/stdc++.h>//前缀和优化版本,不易理解 using namespace std; #define ll long long ; ; ll sum[maxn][maxn]; ll dp[maxn][maxn]; char str[maxn]; int main() { str[]='*'; str[]='*'; scanf(); ll len=strlen(str)-; sum[][]=; dp[][]=; ;i<=len;i++) ;…
# coding:utf-8 import numpy as np from matplotlib import pyplot as plt from matplotlib.patches import Polygon ''' 求函数积分 ''' def func(x): return -(x - 2) * (x - 8) + 40 print(plt.style.available) plt.style.use("ggplot") # 绘制曲线 x = np.linspace(0,…
Phone List Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 27948    Accepted Submission(s): 9204 Problem Description Given a list of phone numbers, determine if it is consistent in the sense tha…
题意:去除数列中的一个数字,使去除后数列中所有数字的gcd尽可能大. 分析:这个题所谓的Coprime Sequence,就是个例子而已嘛,题目中没有任何语句说明给定的数列所有数字gcd一定为1→_→,队友这样解读题目导致我们队的思路完全想歪了,当时真的脑子发懵,为啥没再读一遍题= = 1.求出一个数列的gcd跟计算顺序没关系. 2.如果求去掉下标为i的数字后整个数列的gcd,直接将该数字前的所有数字的gcd(prefix[i-1])和该数字后所有数字的gcd(suffix[i+1])再求一下g…
题意: t组输入,给你一个长度为n的数组,你每次可以从数组中找到a[i]和a[i+1],然后用a[i]+a[i+1]这个新元素来覆盖掉a[i]和a[i+1]的位置(1<=i<n),从而数组长度也减去1 你可以进行任意次这样的操作,输出最后的数组中有多少数,是p的倍数 题解: 给你一个a数组的前缀和数组w,我们保证a[i]>=1,前缀和w[i]都被p取余过 假设i<j,那么如果w[i]和w[j]相等,那也就是说(a[i+1]+a[i+2]+...+a[j])%p == 0,也就是说这…
题目链接 再水一发,构造啊,初始化啊...wa很多次啊.. #include <cstring> #include <cstdio> #include <string> #include <iostream> #include <algorithm> #include <vector> #include <queue> using namespace std; #define MOD 1000000007 #define…
Arc of Dream Time Limit: 2000/2000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 419    Accepted Submission(s): 148 Problem Description An Arc of Dream is a curve defined by following function:wherea0 = A0ai = ai-1…
由式子的性质发现都是线性的,考虑构造矩阵,先有式子,a[i] = ax * a[i-1] + ay; b[i] = bx*b[i-1] +by; a[i]*b[i] = ax*bx*a[i-1]*b[i-1] + ax*by*a[i-1] + bx*ay*b[i-1]+ay*by; s[i] = s[i-1] + a[i-1]*b[i-1]; 由此得到递推式 :设矩阵A= ax 0 0 0 ay 0 bx 0 0 by ax*by bx*ay ax*bx 0 ay*by 0 0 1 1 0 0…
思路:构造矩阵 a[i]*b[i]=ax*bx*a[i-1]*b[i-1]+ax*by*a[i-1]+ay*bx*b[i-1]+ay*by 代码如下: #include<iostream> #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> #include<map> #define ll __int64 #define mod 10000000…
题意:略 构造出矩阵就行了 |   AX   0    AXBY   AXBY       0  |                                                                       |   0     BX    AYBX    AYBX    0  | {a[i-1]   b[i-1]   a[i-1]*b[i-1]  AoD[i-1]  1}*        |   0     0      AXBX      AXBX   0  …
Problem Description An Arc of Dream is a curve defined by following function: where a0 = A0 ai = ai-*AX+AY b0 = B0 bi = bi-*BX+BY What ,,,?   Input There are multiple test cases. Process to the End of File. Each test nonnegative integers as follows:…
标题效果:你就是给你一程了两个递推公式公式,第一个让你找到n结果项目. 注意需要占用该公式的复发和再构造矩阵. Arc of Dream Time Limit: 2000/2000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others) Total Submission(s): 2092    Accepted Submission(s): 664 Problem Description An Arc of Dream is a…