CF#637 C. Nastya and Strange Generator】的更多相关文章

C. Nastya and Strange Generator 题意 有一个随机全排列生成器,给出你一个全排列,让判断是否可以通过这个生成器产生. 生成器工作方式: 第i步为数字i寻找位置pos. 首先pos是一个空位置,定义每个空位置的价值为左边连续有数字的位置数,会为数字i在价值最大的一个或者多个位置中选择一个位置. 比如上图,第三个位置的值是2,第4个位置的值是0,这时4就选择了第3个位置. 思路 写一下就会发现,这个生成器生成的全排列是有规律的. n的全排列 x+y+1 x+y+2...…
D. Nastya and Scoreboard 题意 一块电子屏幕上有n个数字. 每个数字是通过这样7个线段显示的,现在你不小心打坏了k个线段,给出打坏之后的n个数字的显示方式,问之前的屏幕表示的最大数字是多少? 思路 看数据范围感觉就是DP. 我们把n个数字先倒过来,要尽可能的让后面的数字大. dp[i][j][k]表示前i个数字打坏了j个线段最后一个数字为k是否可行. 对于第i个数字,枚举可以变成的数字. 回溯一下即可. 代码 #include<bits/stdc++.h> #defin…
A. Nastya and Rice 网址:https://codeforces.com/contest/1341/problem/A Nastya just made a huge mistake and dropped a whole package of rice on the floor. Mom will come soon. If she sees this, then Nastya will be punished. In total, Nastya dropped n grain…
比赛链接:https://codeforces.com/contest/1341 A - Nastya and Rice 题意 有 n 堆米,每堆质量在 [a-b,a+b] 之间,这些米的总质量是否可能在 [c-d,c+d] 之间. 思路 n 堆米的最小总质量为 n*(a-b),最大总质量为 n*(a+b),即判断区间 [n*(a-b),n*(a+b)] 是否与 [c-d,c+d] 相交. 代码 #include <bits/stdc++.h> using namespace std; voi…
AutoGenerator 是 MyBatis-Plus 的代码生成器,通过 AutoGenerator 可以快速生成 Entity.Mapper.Mapper XML.Service.Controller 等各个模块的代码. 项目结构: 生成前: 生成后: pom.xml: <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>sp…
A. Strange Addition time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Unfortunately, Vasya can only sum pairs of integers (a, b), such that for any decimal place at least one number has digi…
time limit per test 1 second memory limit per test  256 megabytes input standard input output standard output Ivan is playing a strange game. He has a matrix a with n rows and m columns. Each element of the matrix is equal to either 0 or 1. Rows and…
Nastya received a gift on New Year - a magic wardrobe. It is magic because in the end of each month the number of dresses in it doubles (i.e. the number of dresses becomes twice as large as it is in the beginning of the month). Unfortunately, right a…
题目链接:codeforces.com/problemset/problem/1136/B 题目分析 首先,读完题目,看了是个B题,嗯嗯...... 果断找规律,然后交了一波,居然过了!!! 代码区 #include<iostream> #include<cstdio> #include<algorithm> #include<cstring> #include <vector> using namespace std; typedef long…
题目链接:http://codeforces.com/problemset/problem/1136/C 题目分析 看了题目之后,第一想法:任意位置都可以倒置,要是枚举,铁定的超时.所以需要探索规律...... 结果发现,任意的两个数,如果可以交换,其横纵坐标之和一定相同,所以我们只需要用一个数组存储横纵坐标相同的所以点的值,然后判断在的横纵坐标之和相同的情况下,这个数组中所含有的数是否完全一致,有一个数组中所含有的数不相同,那么肯定不满足条件. 代码区 #include<iostream>…