从n个t变化到n个t-1,恰好要n步,并且其中每一步的max值都>=t,所以把50个49当成最终局面,从这里开始,根据输入的K计算初始局面即可. #include<cstdio> #include<iostream> using namespace std; typedef long long ll; ll K; int main(){ cin>>K; int n=50; printf("%d\n",n); ll a=K/(ll)n; ll b…
E - Decrease (Judge ver.) Time limit : 2sec / Memory limit : 256MB Score : 600 points Problem Statement We have a sequence of length N consisting of non-negative integers. Consider performing the following operation on this sequence until the largest…
每次将最大的数减到n以下,如此循环直到符合题意. 复杂度大概是n*n*log?(?). #include<cstdio> #include<iostream> #include<algorithm> using namespace std; int n; typedef long long ll; ll ans,a[60]; int main(){ scanf("%d",&n); for(int i=1;i<=n;++i){ cin&g…
D - Decrease (Contestant ver.) Time limit : 2sec / Memory limit : 256MB Score : 600 points Problem Statement We have a sequence of length N consisting of non-negative integers. Consider performing the following operation on this sequence until the la…
对每个点的取值都取最小的可能值. 那个图最多一个环,非环的点的取值很容易唯一确定. 对于环上的点v,其最小可能取值要么是mex{c1,c2,...,ck}(ci这些是v直接相连的非环点)(mex是).要么是这个值+1. 并且如果环上的一个点的值确定了,其他的值也就唯一确定了. 那么就一共只有两种可能性,枚举一下即可.…
C题,刚开始以为遍历整个树,后来发现二重循环判断就行了 #include<map> #include<set> #include<cmath> #include<queue> #include<stack> #include<vector> #include<cstdio> #include<cassert> #include<iomanip> #include<cstdlib> #in…
AtCoder Regular Contest 093 C - Traveling Plan 题意: 给定n个点,求出删去i号点时,按顺序从起点到一号点走到n号点最后回到起点所走的路程是多少. \(n\le 2e5\) 分析: 可以通过观察发现,无论删去那个点,比全部都走所差距的距离都是\(|a_i-a_{i-1}|-|a_{i+1}-a_i|+|a_{i-1}-a_{i+1}|\) 所以直接枚举即可. #include <bits/stdc++.h> using namespace std;…
AtCoder Regular Contest 095 C - Many Medians 题意: 给出n个数,求出去掉第i个数之后所有数的中位数,保证n是偶数. \(n\le 200000\) 分析: 发现题目范围支持\(nlogn\)做法. 我们可以对这些数字建立一棵平衡树,先全加进去,再一边删除一边find一边再加,非常容易想到的解法,但是真要这么写估计排名高不到哪里去. 考虑删除一个数之后中位数的情况,明显只有两种,一种是你删除的数小于等于中位数,还一种是大于中位数,那么可以先排序找出中位…
AtCoder Regular Contest 102 C - Triangular Relationship 题意: 给出n,k求有多少个不大于n的三元组,使其中两两数字的和都是k的倍数,数字可以重复. 分析: 思考什么样的三个数可以满足这样的要求,当然这三个数都是k的倍数的时候是可以满足的,还有就是这三个数在d对k取模之后都等于k/2也应该是可以的.直接枚举这样的数就可以了. #include <cstring> #include <cstdio> #include <a…
AtCoder Regular Contest 098 C - Attention 题意 给定一个只包含"E","W"字符串,可以花一的花费使他们互相转换.选定一个位置,使位置左边的字符都变成E,右边都变成W所需要的最小花费. 分析 这题纯粹是签到题,做两个前缀和然后直接加就可以了. #include <iostream> #include <cmath> #include <cstring> #include <cstdi…