Codeforces 264 B. Good Sequences】的更多相关文章

题目链接:http://codeforces.com/problemset/problem/264/B 题意:给出一个严格递增的一串数字,求最长的相邻两个数的gcd不为1的序列长度 其实这题可以考虑一下素因数,将每一个数都已是分解为几个不重复的素数,设dp[i]为含有因数i的最长序列有多长 然后遍历一下这串数字,每次更新dp[a[i]]=max(dp[j]+1,dp[a[i]]),j表示a[i]的素因数,再将每个素因数更新为 最大值. for(int i = 1 ; i <= n ; i++)…
B. Good Sequences time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Squirrel Liss is interested in sequences. She also has preferences of integers. She thinks n integers a1, a2, ..., an are …
CodeForces 450B Jzzhu and Sequences (矩阵优化) Description Jzzhu has invented a kind of sequences, they meet the following property: \[f_1=x\] \[f_2=y\] \[f_i=f_{i-1}+f_{i+1}\text {(i>2)}\] You are given x and y, please calculate fn modulo 1000000007 (10…
vjudge 上题目链接:codeforces 446A 大意是说最多可以修改数列中的一个数,求最长严格递增的连续子序列长度. 其实就是个 dp 的思想,想好思路后交上去没想到一直 wa 在第二个测试数据里,丧心病狂啊 T.T,后来才知道原来是分类讨论时没考虑全,而且下标也写拙了. 情况有三: (1) 不作任何修改,直接遍历一遍求出的 in 数组和 de 数组即可.(其实这种情况不会优于(3),可以不用考虑) (2) 修改的元素为最长递增子序列的中间结点,把左边的 in[i - 1] 加上右边的…
http://codeforces.com/contest/447/problem/C 题意:给你n个数的序列,然后让你改变其中的一个数,求得最长上升连续序列的长度值. 思路:先从左边开始求出连续递增序列的值记录在l数组,然后从右边开始再求一遍连续递增序列的值记录在r数组中,然后从2-n-1位置遍历,改变其中的一个数,使得组成一个新的递增序列,求出长度最大值就可以. #include <cstdio> #include <cmath> #include <iostream&g…
Two Merged Sequences 感觉是个垃圾题啊, 为什么过的人这么少.. dp[ i ][ 0 ]表示处理完前 i 个, 第 i 个是递增序列序列里的元素,递减序列的最大值. dp[ i ][ 1 ]表示处理完前 i 个, 第 i 个是递减序列序列里的元素,递增序列的最小值. 然后随便转移转移顺便记录一下路径就好啦. #include<bits/stdc++.h> #define LL long long #define fi first #define se second #de…
447C - DZY Loves Sequences 思路:dp 代码: #include<bits/stdc++.h> using namespace std; #define ll long long const int INF=0x3f3f3f3f; ; int a[N]; int f[N],g[N]; int main() { ios::sync_with_stdio(false); cin.tie(); int n; cin>>n; f[]=; cin>>a[…
Count the number of distinct sequences a1, a2, ..., an (1 ≤ ai) consisting of positive integers such that gcd(a1, a2, ..., an) = x and . As this number could be large, print the answer modulo 109 + 7. gcd here means the greatest common divisor. Input…
Jzzhu has invented a kind of sequences, they meet the following property: You are given x and y, please calculate fn modulo 1000000007 (109 + 7). Input The first line contains two integers x and y (|x|, |y| ≤ 109). The second line contains a single i…
题目链接:https://vjudge.net/problem/CodeForces-450B B. Jzzhu and Sequences time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Jzzhu has invented a kind of sequences, they meet the following proper…