题意:给你一串只含\(4,8,15,16,23,42\)的序列,如果它满足长度是\(6\)的倍数并且有\(\frac {k}{6}\)个子序列是\([4,8,15,16,23,42]\),则定义它是好的,问最少删除多少元素使得序列是好的. 题解:我们开个桶(要离散化)记录这些数字出现的次数,然后线性遍历,当遇到\(4\),我们就直接让它++,否则判断它的前一个数的次数是否大于\(0\),如果是,那么它的前一个数的次数--,它自己次数++,如果前一个数出现的次数为\(0\),那么当前这个数就不能构…
链接: https://codeforces.com/contest/1176/problem/C 题意: You are given an array a consisting of n integers. Each ai is one of the six following numbers: 4,8,15,16,23,42. Your task is to remove the minimum number of elements to make this array good. An a…
D. Recover it! Authors guessed an array aa consisting of nn integers; each integer is not less than 22 and not greater than 2⋅1052⋅105. You don't know the array aa, but you know the array bb which is formed from it with the following sequence of oper…
链接: https://codeforces.com/contest/1176/problem/B 题意: You are given an array a consisting of n integers a1,a2,-,an. In one operation you can choose two elements of the array and replace them with the element equal to their sum (it does not matter whe…
链接: https://codeforces.com/contest/1176/problem/A 题意: You are given an integer n. You can perform any of the following operations with this number an arbitrary (possibly, zero) number of times: Replace n with n2 if n is divisible by 2; Replace n with…
B. Merge it! 题目链接:http://codeforces.com/contest/1176/problem/B 题目 You are given an array a consisting of n integers a1,a2,…,an In one operation you can choose two elements of the array and replace them with the element equal to their sum (it does not…
A. Divide it! 题目链接:http://codeforces.com/contest/1176/problem/A 题目 You are given an integer n You can perform any of the following operations with this number an arbitrary (possibly, zero) number of times: Replace n with n2 if n is divisible by 2;Rep…
题目地址:http://codeforces.com/contest/1176/problem/F 思路:其实就是一个01背包问题,只是添加了回合和每回合的01限制,和每当已用牌数到了10的倍数,那张卡会触发double攻击. 因为卡使用的多少会触发double效果,所以我们要记录攻击的同时记录卡的使用次数,可以由01背包dp[N][N]改变, 第一个维度是当前是第几个回合,第二个维度是记录卡在用了n张的情况下造成的攻击力,但是dp[N][N](N <= 2e5), 占用内存太大显然不行.于是想…
传送门 A. Divide it! •题意 给定一个数n, 每次可以进行下列一种操作 1.如果n可以被2整除,用n/2代替n 2.如果n可以被3整除,用2n/3代替n 3.如果n可以被5整除,用4n/5代替n 如果可以经过上述操作使得 n 变为 1,输出最小操作次数,反之,输出-1: •思路 n/2 < 2n/3 < 4n/5 要想操作次数最少,优先操作 1 > 2 > 3: •代码 #include<bits/stdc++.h> using namespace std…
题目链接:http://codeforces.com/contest/675/problem/C 给你n个bank,1~n形成一个环,每个bank有一个值,但是保证所有值的和为0.有一个操作是每个相邻的bank之间可以转钱,让你用最少的操作使每个bank的值为0. 一开始没什么思路,看了一下别人的题解,果然还是还是native... 要是让操作次数变少,首先划分和为0的区间个数要尽量多,比如一个区间的长度为k,那么他操作次数为k - 1,所以总的操作次数就是(n - 区间的个数). 那么要算出区…