E - Nastya and King-Shamans 题目大意:有n个数,每一次操作更改一个数,每次操作之后问你是否有一个数等于其前面所有数的和. 思路:好题,想了很久没想出来,看了题解,主要思想就是满足条件的数会成倍增长,如我们知道了 1 - i 里面没有满足条件的数, 那么我们找一个最小的 j 满足 a[ j ] >= sum(1, i),j就可能成为一个答案, 我们check一下,如果可以就是这个点,如果不行那么 不可能前缀就从 1 - i 变成了 1 - j, 这个过程最多 执行log…
题意 给出一个长度为 \(n\) 的序列 \(\{a_i\}\) , 现在会进行 \(m\) 次操作 , 每次操作会修改某个 \(a_i\) 的值 , 在每次操作完后你需要判断是否存在一个位置 \(i\), 满足 \(\displaystyle a_i = \sum_{j=1}^{i - 1}a_j\) 并求任意一个 \(i\) . \(n, m ≤ {10}^5 , 0 ≤ a_i ≤ {10}^9\) 题解 考虑一个暴力,不妨首先从 \(i = 1\) 开始判断是否合法,由于 \(a_i\)…
C. Nastya Is Transposing Matrices time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave he…
A. Nastya and an Array time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Nastya owns too many arrays now, so she wants to delete the least important of them. However, she discovered that this…
失踪人口突然回归……orz.题解还是有必要写的,虽然估计只有自己(?自己也不一定看得懂)看得懂. 题目链接:http://codeforces.com/contest/992/problem/D 题目大意:给出n个数字a和一个k,求数列a中的子区间aa满足aa的和乘k等于aa的积.(a<=1e8,n<=2e5,k<=1e5) 这道题没找到官方题解,所以看了一下standing rank1的dalao的代码. 鸣谢 dotorya 第一眼就觉得短,非常短.赛上把我卡得很恶心的1的情况竟然被…
链接:https://codeforces.com/contest/1136/problem/B 题意: 有n个井盖,每个井盖上有一个小石头. 给出n和k,k表示刚开始在第k个井盖上方. 有三种操作,左右移动,扔石头到任意一个井盖,下到井盖里拿金币. 只有井盖上没有石头才能下井盖. 求捡完全部金币的最小步数. 思路: 因为刚开始就在一个井盖上方, 所有先用选相邻的井盖堆石头,把这两个井盖金币捡到的步数和为6,其他的井盖步数和为(n-2)*3. 即共n*3同时,考虑先走那个方向,往左走的多余步数为…
链接:https://codeforces.com/contest/1136/problem/A 题意: 给n个区间,每个区间范围不超过100,n不超过100. 给一个位置k,1-(k-1)是遍历过的位置,求没有完全遍历完的区间. k处于区间中时,表示区间没有遍历完 思路: 暴力 代码: #include <bits/stdc++.h> using namespace std; typedef long long LL; const int MAXN = 1e5 + 10; int a[MAX…
B. Nastya Studies Informatics time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Today on Informatics class Nastya learned about GCD and LCM (see links below). Nastya is very intelligent, so s…
Nastya and an Array 输出有几种不同的数字 #pragma comment(linker, "/STACK:102400000,102400000") #ifndef ONLINE_JUDGE #include "stdafx.h" #else #include<bits/stdc++.h> #endif using namespace std; typedef long long lint; typedef vector<int…
这道题,神仙贪心题... 题意就是我给出数的顺序,并给出多个交换,每个只能用于相邻交换,问最后一个元素,最多能往前交换多少步. 我们考虑这样一个问题,如果一个这数和a[n]发生交换,那么这个数作为后面的数能和前交换的数已经没有任何效果了. 但是这个数如果没有往后,他将在想要被交换那个数的前面,就算,前面的数找到满足了,也必须要把这个数往前放,并把这个数往后放,才行. 我们交换只能考虑这种情况. 4 3 2 1 我们有 4 3 4 2 4 1 那么整体往前移动,4移动到最后. 而且我们这样考虑,为…