↓ Skip to main content
  1. Tags/

思维题

2018

codeforces edu #51 C. Vasya and Multisets (思维题)

·661 words·2 mins
题目链接 题意:有n个数,现在要分成2个集合,使得2个集合中,仅出现1次的数的个数相同,问是否有解,以及具体的分法。 思路: 一开始考虑出现多个的数的思路麻烦了,比如对于出现2次的某个数x,与其一个集合中分得一个,使得两个结合中,仅出现1次的数的个数各+1,还不如都放在同一个集合中,使得仅出现1次的数的个数不增加。

2017

codeforces div 1 443 A. Short Program (位运算的理解)

·537 words·2 mins
题目链接: 题目链接 题意: # 一段程序,最多5E5个操作,每个操作的格式为 <opt,x> ,opt表示位或,位异或,位与 三种位运算的一种,x表示范围0..1023的数。现在要求将该程序化简至最多 5个操作,使得对于0..1023的输入,输出与该程序同样的结果。

2016

hdu 3193 find the hotel (思维题)

·403 words·1 min
hdu3193题目链接 题意:给出n个price 和distance,找到一个集合,集合中的每对在全集中找不到比他price和distance都要小的元素。小于是严格的。 思路:一开始以为找到最小值就好。。。结果漏洞百出。。这题还找不到题解。。。大概是太简单了。。? 看了一份代码大概看明白了。。。

hdu 4451 Dressing (计数,思维题)

·487 words·1 min
http://acm.hdu.edu.cn/showproblem.php?pid=4451 题意:N clothes, M pants and K shoes,然后给出p个不合法的搭配,形式是“clothes x pants y” or “pants y shoes z”.” 问有多少种合法的方案。 思路:一开始觉得是容斥。。当然可以。。但是实际上,不合法的搭配的形式比较简单,每种不合法的发配都是两个两个的不合法,以及每种不合法的形式都有pants,那么我们就可以通过先确定pants,对于每种pants,方案数就是能和当前pants搭配的clothes数,乘以能和当前pants搭配的shoes数,然后累加每种pants的答案即可。

2015

codeforces #322 div 2 B. Luxurious Houses (思路)

·578 words·2 mins
B. Luxurious Houses time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let’s enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all the houses with larger numbers. In other words, a house is luxurious if the number of floors in it is strictly greater than in all the houses, which are located to the right from it. In this task it is assumed that the heights of floors in the houses are the same.

uva 1587 Box(思路)

·527 words·2 mins
给6个矩形的长和宽(或者宽和长),问这六个矩形能否组成一个长方体. 思路比较简单,不过需要注意的地方有点多. 首先由于长和宽的顺序为止,所以要处理一下(一开始只处理了后来读入的五组,没有处理单独读入的第一组,差评)