思维
文章平均质量分 62
ACM思维题
PushyTao
这个作者很懒,什么都没留下…
展开
-
[leetcode] 1675. 数组的最小偏移量 | 思维贪心 | 大疆笔试题
leetcode1675原创 2022-08-12 23:50:04 · 240 阅读 · 0 评论 -
APAC 2013 部分题解 | 训练记录
0704 APAC2013 训练记录原创 2022-07-08 00:27:19 · 415 阅读 · 0 评论 -
[leetcode 324] 摆动排序 II 思维+排序
给定一些数,要把他们重新排列成满足:< > < > < …关系的序列思路:从小到大排序,然后将奇数位,从左向右从大到小放置;将偶数位从左向右,从大到小放置,即可得到满足的结果序列Code:...原创 2022-06-29 18:23:12 · 113 阅读 · 0 评论 -
[Gym 102423]-Elven Efficiency | 思维
gym_102423_C,Elven Efficiency原创 2022-06-28 22:17:57 · 213 阅读 · 0 评论 -
Greedy Takahashi——UPC
题目描述Takahashi has A cookies, and Aoki has B cookies. Takahashi will do the following action K times:·If Takahashi has one or more cookies, eat one of his cookies.·Otherwise, if Aoki has one or more...原创 2020-03-17 23:38:02 · 177 阅读 · 0 评论 -
Buy an Integer——UPC
题目描述Takahashi has come to an integer shop to buy an integer.The shop sells the integers from 1 through 109. The integer N is sold for A×N+B×d(N) yen (the currency of Japan), where d(N) is the number...原创 2020-03-17 23:28:07 · 261 阅读 · 0 评论 -
Prediction and Restriction——UPC
题目描述At an arcade, Takahashi is playing a game called RPS Battle, which is played as follows:·The player plays N rounds of Rock Paper Scissors against the machine. (See Notes for the description of R...原创 2020-03-17 23:42:02 · 160 阅读 · 0 评论 -
Practical Skill Test——AT
题目描述We have a grid with H rows and W columns. The square at the i-th row and the j-th column will be called Square (i,j).The integers from 1 through H×W are written throughout the grid, and the inte...原创 2020-03-21 23:49:53 · 235 阅读 · 0 评论 -
Rem of Sum is Num——UPC
题目描述Given are a sequence of N positive integers A1,A2,…,AN, and a positive integer K.Find the number of non-empty contiguous subsequences in A such that the remainder when dividing the sum of its el...原创 2020-03-17 23:31:27 · 170 阅读 · 0 评论 -
[USACO 2012 Feb B]Moo - 规律
评测网址某字符串由m o 两个字符构成而且构成的字符串为前一个字符串 + m + o * (i+2) + 前一个字符串 *(i+2)指的是数量问字符串第n个字符是什么ll a[maxn], n;char ans[5] = {'m', 'm', 'o', 'o'};void f(ll num) { int pos = 0; if(num <= 3) { cout << ans[num] << endl; return原创 2021-08-15 14:51:45 · 479 阅读 · 0 评论 -
[HDU7073] Integers Have Friends 2.0 -随机大法好
output234题意:找到最大的一个集合,使得集合内所有元素 % m(>=2)问最大的集合大小对于第一组来讲:可以选择m == 2 or 3对于第二组来讲:可以选择m == 5在我们取m == 2的情况下,答案为 ⌈n2⌉\lceil \frac{n}{2} \rceil⌈2n⌉选择两个位置,这两个数的位置均在答案中的可能性至少为14\frac{1}{4}41,反之可能性为34\frac{3}{4}43,假如重复取30次,则:可以看作为0所以方法是可靠的选.原创 2021-08-20 20:48:31 · 204 阅读 · 0 评论 -
Xor Sum 2二分/尺取 区间异或和等于区间和的方案数
题目描述There is an integer sequence A of length N.Find the number of the pairs of integers l and r (1≤l≤r≤N) that satisfy the following condition:Al xor Al+1 xor … xor Ar=Al + Al+1 + … + ArHere, xor denotes the bitwise exclusive OR.Definition of XORCons原创 2021-07-27 12:44:15 · 299 阅读 · 0 评论 -
[leetcode] 798 得分最高的最小轮调 - 思维dp
题目链接轮调实际上是这个样子的:每次讲最前面的元素放到数组最后,然后将所有元素集体向前移动一位在当前值a[i]≤ia[i] \leq ia[i]≤i的时候会获得111分,问最大的的分是多少?先说明一个事实:一次轮调之后,对于除了最前面的每个数,他的下标会减小111,而对于最前面的那个数,他的下标直接变为最大大致分为以下三种情况:本来a[i]a[i]a[i]就小于下标iii,轮调之后下标减小值不变,所以依旧会获得111分本来a[i]==ia[i] == ia[i]==i,轮调之后,下标减小原创 2022-03-09 21:26:53 · 199 阅读 · 0 评论 -
[leetcode] 1 比特与 2 比特字符-水题
题目链接指针iii从000开始往后走,如果当前位置的值为000,则一定是第一种情况,指针向右移一位如果说当前值为111,则一定是第二种情况,指针向右移动两位,如果说最终i==bits.size()−1i == bits.size() - 1i==bits.size()−1那么说就是一个合法的class Solution {public: bool isOneBitCharacter(vector<int>& bits) { int i;原创 2022-03-05 20:33:36 · 311 阅读 · 0 评论 -
[Codeforces 1589D] Guess the Permutation | 交互 思维 二分
题目链接题意多组输入:{每组给出一个n,有一个长度为n的数列,在开始的时候ai=ia_i=iai=i,有三个数i,j,ki,j,ki,j,k数列反转了[i,j−1][j,k][i,j-1][j,k][i,j−1][j,k]要求出这三个数,可以对系统进行询问[l,r][l,r][l,r]区间内逆序对的个数,会返回这个值}思路:对于这个反转之后的数列来说,[1,i][1,i][1,i]之内的逆序对的个数为0所以在左端点固定(= 1)的情况下,二分右端点找到这个iii然后对于一段反转之后的数原创 2021-11-18 17:26:03 · 399 阅读 · 0 评论 -
[2018 ICPC 青岛] 解题记录ing
M. Function and Function队友说直接暴力即可#include <cmath>#include <cstdio>#include <iostream>#include <algorithm>using namespace std;typedef long long ll;int get(int x) { if (x == 0) return 1; int sum = 0; while (x) { int d = x原创 2021-11-02 21:33:06 · 209 阅读 · 0 评论 -
[NCPC2021] Antenna Analysis | 思维递推
题目描述Åke has heard that there may be some suspicious 5G radiation in his city. To test this, he uses the antenna on his roof to measure the 5G level each day. However, he does not know how he should analyze the data.We are given the measurements for n con原创 2021-11-01 20:36:53 · 311 阅读 · 0 评论 -
[UCF HSPT 2021] Sharon’s Sausages | 思维 暴力
DescriptionSharon is a food-loving individual, and recently he has discovered that he loves the taste of different types of sausages!When he was invited to the HSPT potluck, he decided that he would contribute 4 sausages for the cause in order to spread原创 2021-09-16 00:40:58 · 127 阅读 · 0 评论 -
[Nowcoder] Browser Games-2021牛客多校10-A | Hash /压缩Trie
DescriptionIn the upcoming nnn days, nnn browser games will be released on a new website. According to the plan, the administrator will release a new game per day. Users have to open the corresponding URL (Uniform Resource Locator) and get feedback from t原创 2021-08-29 21:24:42 · 258 阅读 · 0 评论 -
[Atcoder ARC124] XOR Matching 2-小思维 | 暴力
样例输入 Copy【样例1】31 2 36 4 7【样例2】20 10 2【样例3】2414911005 70152939 282809711 965900047 168465665 337027481 520073861 20800623 934711525 944543101 522277111 580736275 468493313 912814743 99651737 439502451 365446123 198473587 285587229 253330309 59.原创 2021-08-15 11:39:05 · 257 阅读 · 0 评论 -
Codeforces 1554C - Mikasa MEX
input53 54 63 269 696123456 654321output430640530866给出n,m从n ^ 0 -> n ^ m中最小为出现的非负整数int main() { int _ = read; while (_--) { int n = read, m = read; if(n > m) { puts("0"); continue; .原创 2021-08-13 12:47:58 · 182 阅读 · 0 评论 -
Codeforces 220B-Little Elephant and Array-扫描线 & 树状数组
首先放上学长博客链接感谢宇巨抛过来的题,本人在抛题现场题意:给出一个长度为n的数组,有m个询问,每次询问给出一个区间,问这个区间内有多少个数x恰好出现x次考虑将询问离线,对每一个询问的右端点,将其左端点以及询问的id进行保存,维护其左端点,用结果 segVal(l,r) 表示当前这一段[l,r]之间的合法方案的个数然后观察序列[2,2,2,2]假设我们用sum[]来记录维护的左端点的贡献,用树状数组来进行操作开始时sum[1] -> sum[4] 全为0rs原创 2021-08-11 13:20:56 · 181 阅读 · 1 评论 -
[AtCoder ARC098] Donation| 建图 | 树型dp
Donationinput1:4 53 11 24 16 21 22 32 41 43 4input2:5 86 415 1315 1915 120 71 31 41 52 32 42 53 54 5output2:44input3:9 10131 298 79242 32231 38382 82224 22140 88209 70164 646 81 61 41 34 74 93 73 95 9原创 2021-08-10 20:05:32 · 117 阅读 · 0 评论 -
2021杭电多校5-Arrary-hdu7020
ArrayTime Limit: 15000/8000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Others)Total Submission(s): 965 Accepted Submission(s): 312Problem DescriptionGiven an integer array a[1…n].Count how many subsegment [L,R] satisfying R−L+1≥1 and t原创 2021-08-07 13:15:21 · 328 阅读 · 0 评论 -
2021杭电多校第三场-Road Discount-wqs二分+最小生成树
DescriptionThere are n cities in Byteland, labeled by 1 to n. The Transport Construction Authority of Byteland is planning to construct n−1 bidirectional roads among these cities such that every pair of different cities are connected by these roads direct原创 2021-08-04 23:44:24 · 3744 阅读 · 0 评论 -
Say No to Palindromes
Let’s call the string beautiful if it does not contain a substring of length at least 2, which is a palindrome. Recall that a palindrome is a string that reads the same way from the first character to the last and from the last character to the first. For原创 2021-08-04 23:21:35 · 262 阅读 · 0 评论 -
Mikasa #735-div2
题意:找到n ^ 1 … n ^ m中最小为出现的非负整数int main() { int _ = read; while (_--) { int n = read, m = read; if(n > m) { puts("0"); continue; } ++m; int ans = 0; for (int i = 30; i >= 0; i-.原创 2021-07-30 12:18:41 · 106 阅读 · 0 评论 -
子序列-反转区间求最长不下降子序列
题目描述小Z有一个01序列A=(A1,A2,A3,…,An)。他可以进行一次操作:选择一个区间L,R将其反转。例如,对于序列A=(1,0,0,1,1),当L=2,R=4时,原序列将变为(1,1,0,0,1)。小Z希望:通过这一次反转操作,使得这个序列的最长不下降子序列的长度尽可能的大,并想让你输出这个最大值。一个序列的不下降子序列定义为:对于一个序列(p1,p2,…,pk)满足1≤p1<p2<…<pk≤n(n≤819200)且Ap1≤Ap2≤…≤Apk。则序列(Ap1,Ap2,…,原创 2021-07-25 20:49:51 · 423 阅读 · 0 评论 -
Codeforces Round #723 (Div. 2)B. I Hate 1111
DescriptionYou are given an integer x. Can you make x by summing up some number of 11,111,1111,11111,…? (You can use any number among them any number of times).For instance,33=11+11+11144=111+11+11+11InputThe first line of input contains a single int原创 2021-07-21 20:34:33 · 222 阅读 · 0 评论 -
2021-07-21训练日记upc联通数(思维)|赛博朋克(唯一分解)
A. 联通数题目描述数学高手小G最近发现了一种新型的数!他首先在草稿纸写下任意长度的数字串kkkkkkkkkkk…(1≤k≤9)并在其中间添加加号,且相邻两个加号之间至少含有两个数字k (默认数字串第一个数字前与最后一个数字后也有两个加号),然后对其进行求和得出一个新的数。像这样得出的数他将其定义为 “k联通数 ” 。小G对于他的发现感到非常的自豪, 像数字854就能表示为77+777,因此854是7联通数。小G现在非常好奇, 究竟有哪些数可以是k联通数呢?他想考验一下你。询问T次,每次给定两原创 2021-07-21 20:26:41 · 543 阅读 · 9 评论 -
Harry Potter and The Vector Spell-gym101669D(矩阵的秩-并查集)
Sample Input3 3 2 1 3 2 1 2 2 2 3 Sample Output2Sample Input 24 33 1 2 3 1 11 21 3Sample Output 23题意:给出一个0 1矩阵,这个矩阵中每一列有且只有两个1,求这个矩阵的秩输入一行中1的数量x,然后后面x个数代表1出现的列位置求出这个矩阵的秩方法:思维并查集将每一列的两个1所在的行编号连一条边,然后求一下最小生成树就好其实就是我们维护一个并查集,在这个并查集里面.原创 2021-05-08 10:56:13 · 185 阅读 · 0 评论 -
Group Project-思维
链接来源:牛客网题目描述:The big day has fifinally arrived: today you are going to form groups of two in which you will do the end-of-the-year project. When you arrive at school, you learn that the teacher of the other class is sick, and that your teacher, Mr. B.A原创 2021-04-12 15:30:12 · 248 阅读 · 0 评论 -
Triangular Collection思维
题目描述Call a set of positive integers triangular if it has size at least three and, for all triples of distinct integers from the set, a triangle with those three integers as side lengths can be constructed.Given a set of positive integers, compute the nu.原创 2021-04-12 13:50:33 · 283 阅读 · 0 评论 -
2021年广工大第十五届文远知行杯-B找山坡-栈
找山坡时间限制:C/C++ 3秒,其他语言6秒空间限制:C/C++ 262144K,其他语言524288K64bit IO Format: %lld题目描述母牛哥在电脑面前坐久了,想站起来看看窗外的小山坡,于是就想出了这个问题:给定一个大小为n的数组a,序号从1开始,计算:max{ R - L | 1 <= L <= R <= n, a[L] == a[R], 对于所有i (L <= i <= R), 满足a[i] >= a[L] }.也就是找到两个坐原创 2021-03-30 13:58:56 · 1351 阅读 · 2 评论 -
Early Orders单调栈
链接:https://ac.nowcoder.com/acm/contest/12606/E来源:牛客网题目描述You are given a list of integers n and a number k.It is guaranteed that each i from 1 to k appears in the list at least once.Find the lexicographically smallest subsequence of x that containsea原创 2021-03-10 19:47:56 · 140 阅读 · 0 评论 -
edu99 div.2 Sequence and Swaps优雅的暴力
time limit per test1.5 seconds memory limit per test512 megabytes inputstandard input outputstandard outputExampleinput64 12 3 5 45 61 1 3 4 41 1022 1011 92 1012 115 1881 324 218 413 324output...原创 2020-12-01 21:07:31 · 166 阅读 · 3 评论 -
Educational Codeforces Round 98 (Rated for Div. 2)B-Toy Blocks
B. Toy Blocks time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard outputYou are asked to watch your nephew who likes to play with toy blo...原创 2020-11-21 12:26:34 · 349 阅读 · 3 评论 -
小思维题-蚂蚁感冒——蓝桥杯
[蚂蚁感冒](https://www.acwing.com/problem/content/description/1213/)Description长100厘米的细长直杆子上有n只蚂蚁。它们的头有的朝左,有的朝右。每只蚂蚁都只能沿着杆子向前爬,速度是1厘米/秒。当两只蚂蚁碰面时,它们会同时掉头往相反的方向爬行。这些蚂蚁中,有1只蚂蚁感冒了。并且在和其它蚂蚁碰面时,会把感冒传染给碰到的蚂蚁。请你计算,当所有蚂蚁都爬离杆子时,有多少只蚂蚁患上了感冒。Input第一行输入一个整数n (1&l原创 2020-09-24 15:05:42 · 176 阅读 · 0 评论 -
UPC-混合训练第十五场
gift题目描述战争结束,A国和B国的元首决定两国友好相处,于是城市之间就有互相送礼的情况。参与这次相互协助计划中有n个A国的城市和m个B国的城市。作为A国的重臣,小Q了解到每一个A国的城市送出了ai份礼物,B国的城市收到了bi份礼物,城市之间不会重复送礼,并且A国和B国自己的城市之间不会送礼。有一句老话“眼见为实,耳听为虚”,现在小Q想知道是否存在一种送礼的方案使得每一个城市都满足要求。输入第一行一个整数T,表示小Q询问的次数。接下来有T组询问,每一组询问第一行为两个正整数n,m,表示A国的原创 2020-05-11 22:59:10 · 227 阅读 · 0 评论 -
bard-upc
题目描述每天晚上,村民们都会在火堆旁集会和唱歌。在所有村民中,有一位歌声动听的吟游诗人。每天晚上,如果他出席晚会,他就会为大家奉献一首全新的歌曲,然后那个晚上也将没有任何其他歌曲被演唱。如果他没有参加,那么其他村民就会唱歌,交换所有他们已经知道的歌曲。给出连续E个晚上的出席情况,输出所有知道全部歌曲的村民。输入第一行包含一个整数N,表示村民的数量。村民被编号为1到N,其中,1号村民即为吟...原创 2020-05-02 17:23:18 · 391 阅读 · 0 评论