【codeforces 438D】The Child and Sequence】的更多相关文章

[原题题面]传送门 [大致题意] 给定一个长度为n的非负整数序列a,你需要支持以下操作: 1:给定l,r,输出a[l]+a[l+1]+…+a[r]. 2:给定l,r,x,将a[l],a[l+1],…,a[r]对x取模. 3:给定k,y,将a[k]修改为y. [数据范围] n,m<=100000,a[i],x,y<=109. [题解大意] 维护最大值和区间和,然后通过最大值有没有超过x来判断需不需要取模操作. [code] #include<bits/stdc++.h> using…
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Chloe, the same as Vladik, is a competitive programmer. She didn't have any problems to get to the olympiad like Vladik, but she was confused by…
Yet Another Number Sequence Description Everyone knows what the Fibonacci sequence is. This sequence can be defined by the recurrence relation: F1 = 1, F2 = 2, Fi = Fi - 1 + Fi - 2 (i > 2). We'll define a new number sequence Ai(k) by the formula: Ai(…
At the children's day, the child came to Picks's house, and messed his house up. Picks was angry at him. A lot of important things were lost, in particular the favorite sequence of Picks. Fortunately, Picks remembers how to repair the sequence. Initi…
Codeforces 3 D 题意:有一个括号序列,其中一些位置是问号,把第\(i\)个问号改成(需要\(a_i\)的代价,把它改成)需要\(b_i\)的代价. 问使得这个括号序列成立所需要的最小代价. 思路1: 这个是正统的贪心. 首先我们假设所有的位置上都是),那么我们在从左向右扫描的途中会发现一些问题. 比如:我们原来的序列是(??),现在假设成了())),那么在第三个字符处就会发现我们的打开的左括号数量为\(-1\),这是肯定不行的,所以我们必须把第二个字符或者第三个字符改成左括号以把左…
[codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=2000),问满足[数列长度是k && 数列中每一个元素arr[i]在1~n之间 && 数列中元素可以重复]的数列有多少个?结果对10^9+7取余 解题思路:dp[i][j]表示长度是j,最后一位是i的种数 if(kk%i==0) dp[kk][j+1]+=dp[i][j] #inc…
[题目链接]:http://codeforces.com/problemset/problem/466/D [题意] 给你n个数字; 让你选择若干个区间; 且这些区间[li,ri]; 左端点不能一样; 右端点也不能有一样的; 你能把这些区间内的元素递增1; 问你把所有的n个元素都变成h有多少种方案;. [题解] 设dp[i][j]; 设前i个数字都已经变成h,且有j个区间的左端点没有被匹配的方案数; 每个位置都有些一些选择; '-' 什么都不放 ']' 放一个右端点在这个位置; ']['放一个右…
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output A function is called Lipschitz continuous if there is a real constant K such that the inequality |f(x) - f(y)| ≤ K·|x - y| holds for all . We'll…
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Andrewid the Android is a galaxy-famous detective. He is now investigating a case of frauds who make fake copies of the famous Stolp's gears, pu…
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Arthur has bought a beautiful big table into his new flat. When he came home, Arthur noticed that the new table is unstable. In total the table A…