—思维题
MissZhou要努力
不晓日月,不辩兰艾,终日碌碌,安与燕雀相随乎
展开
-
UVA 11388 GCD LCM 思维题==
根本用不上lcm gcd什么的==The GCD of two positive integers is the largest integer that divides both the integers without any remainder. The LCM of two positive integers is the smallest positive int原创 2015-07-01 08:55:29 · 457 阅读 · 0 评论 -
codeforces22c System Administrator【给定一个割顶输出边 BCC】
DescriptionBob got a job as a system administrator in X corporation. His first task was to connectn servers with the help of m two-way direct connection so that it becomes possible to transmit原创 2016-05-08 18:32:08 · 905 阅读 · 0 评论 -
nefu1173Dipper Landlord【乱搞】
The “Dipper Landlord” is a card game played by three people. In each game, there is a player is the landlord, the other 2 are farmers, each game score is x=6×2y (y is a non negative integer). If the L原创 2016-05-10 09:57:41 · 769 阅读 · 0 评论 -
CodeForces 426BSereja and Mirroring
貌似很久没写博客了,主要是由于C#大作业(哭,这个题是为数不多周赛没做出来又想起来继续回去做的(主要是由于这次收官之作成绩太惨烈),想来也确实不难,自己又一次把题想难了成狗的把自己绕进去了orz。一看到找镜面的折叠次数,非得用二进制结尾的0的个数把最小的层数表示出来,蠢不蠢??每次都折半多好呢→_→第二次看题的时候又误认为存在内部镜面对称、外部不是2的倍数的情况(好像没说明白,反正想的不对,不要在原创 2015-12-21 18:47:40 · 453 阅读 · 0 评论 -
nefu643teacher Li【字符位异或】
很久以前的题了,翻看自己林大oj的没A的题,看到这个,貌似是上学期孙大神出的周赛的题,怎么拖了这么久orz,现在看来就是小case嘛,就像去年那会做bestcoder,第二个题根本就做不出,现在憋一个多小时也能1A了descriptionThis time,suddenly,teacher Li wants to find out who have原创 2016-01-03 11:26:09 · 542 阅读 · 0 评论 -
CodeForces 417E Square Table【随机数】
DescriptionWhile resting on the ship after the "Russian Code Cup" a boy named Misha invented an interesting game. He promised to give his quadrocopter to whoever will be the first one to make a re原创 2015-12-30 16:47:24 · 590 阅读 · 0 评论 -
CodeForces 305C Ivan and Powers of Two【set】
这个题啊,纠结了本公举一中午,知道如果出现了重复的,就要往后移,差点就把自己想的恶心的bool 数组付诸实现了,==既然是思维的题,借助了STL的特性是再正常不过的了,既然想写数组,先应该想想Set这货啊,vector这货虽是不定长数组,但是不排序,不去重。这个题还用到的一个特性是2*(2^n+2^n)=2^(n+1)所以如果遍历的时候,当前位存在了,那么很自然的他俩就没了,组合成大一倍的原创 2015-12-30 15:34:28 · 484 阅读 · 0 评论 -
CodeForces 305B Continued Fractions【递推的分式】
今天下午把最近一段时间CF做过的题整理下先说着今天做的两个侮辱智商的题==DescriptionA continued fraction of height n is a fraction of form . You are given two rational numbers, one is represented as and the other one is原创 2015-12-30 15:16:15 · 630 阅读 · 0 评论 -
2015多校联合第四场hdu5327Olympiad 递推
Problem DescriptionYou are one of the competitors of the Olympiad in numbers. The problem of this year relates to beatiful numbers. One integer is called beautiful if and only if all of its digita原创 2015-09-10 20:48:53 · 533 阅读 · 0 评论 -
hdu4925Apple Tree【水】2014多校联合
Problem DescriptionI’ve bought an orchard and decide to plant some apple trees on it. The orchard seems like an N * M two-dimensional map. In each grid, I can either plant an apple tree to get one a原创 2016-06-29 10:01:49 · 603 阅读 · 0 评论 -
Wannafly挑战赛9 A 找一找 C 列一列
A 题目链接链接:https://www.nowcoder.com/acm/contest/71/A来源:牛客网给定n个正整数,请找出其中有多少个数x满足:在这n个数中存在数y=kx,其中k为大于1的整数输入描述:第一行输入一个n接下来一行输入n个正整数ai输出描述:输出符合条件个数原创 2018-02-03 10:21:16 · 249 阅读 · 0 评论 -
牛客练习赛11E 求最值
题目链接链接:https://www.nowcoder.com/acm/contest/59/E来源:牛客网给你一个长为n的序列a 定义f(i,j)=(i-j)2+g(i,j)2 g是这样的一个函数 求最小的f(i,j)的值,i!=j输入描述:第一行一个数n之后一行n个数表示序列a输出描述:输出一行一个数表示答案原创 2018-02-03 10:12:51 · 386 阅读 · 0 评论 -
面试算法——双指针的应用leetcode 42. Trapping Rain Water
.给定一个非负数的数组,代表一个容器。例如数组[0,1,0,2,1,0,1,3,2,1,2,1],就是以下图形中黑色的部分。如果用这个容器接水的话,请问可以接多少水?还以这个数组为例, 可以接6格水,就是以下图形中蓝色的部分。 要求:实现时间复杂度O(N),额外空间复杂度O(1)的解法注:因为没地方提交,所以只写思路了QAQ做法:首先要注意的是,围出水的体积(面积)是总体的和,而不原创 2016-08-10 14:11:16 · 2342 阅读 · 0 评论 -
弱校联萌十一大决战之厉兵秣马H. Hanoi Towers poj3572
The “Hanoi Towers” puzzle consists of three pegs (that we will name A, B, and C) with n disks of different diameters stacked onto the pegs. Initially all disks are stacked onto peg A with the smalle原创 2015-10-06 11:05:17 · 918 阅读 · 4 评论 -
codeforcesB - Arpa’s obvious problem and Mehrdad’s terrible solution 【思维】
There are some beautiful girls in Arpa’s land as mentioned before.Once Arpa came up with an obvious problem:Given an array and a number x, count the number of pairs of indicesi, j (1 ≤ i j ≤ n)原创 2016-12-13 10:55:26 · 715 阅读 · 0 评论 -
hdu5813Elegant Construction【构造 2016多校联合第七场】
已知n个点,要求添加任意有向边(没有重边和环)使得每个点能且只能到达ai个点(不包括自己),输出边一看就乱搞啊,队友开始想到的是要更新每一个可以到达的点数,写的时候就卡在了怎样才能除去加重的那些点的点数这个问题上。一看题解恍然大悟。既然是要连点,人家也没说非得连最少的边数啊,只要点数凑够了就好啦。题解中的做法是连接比这个点ai值小(和等于)的所有点,这么看来,如果ai值比这个点的序号大于(和等于),那么就只能输出no可是有这样一个问题:我这一步要连得那些点中有些点是可能到达不止一个点的,会不会存原创 2016-08-10 15:46:33 · 473 阅读 · 0 评论 -
bestcoder两周年前三题hdu5718,5719,5720
一周多上山实习只学了一些python,做题的手感差了好多QAQ,昨天晚上最开始电脑还更新重启折腾了好久,换成台式机做的,只做了一个题居然rating还涨了168,始料未及前三个都是乱搞(第三个有一点贪心的意思hdu5718OracleAccepts: 599Submissions: 2576Time Limit: 8000/4000 MS (Java/Oth原创 2016-07-18 17:25:14 · 1326 阅读 · 0 评论 -
hdu4889Scary Path Finding Algorithm【构造】搞坏spfa-slf 2014多校联合
题意:给出spfa_slf优化的代码,要你写示例使得代码坏掉==做法:首先应该分析这堆代码,每次拿出队首元素并弹出,查找队首元素相连的点,与现在的队首元素比较,距离比队首元素大的放到队尾,小的放到队首。每个元素跳出的次数大于给定值的时候输出”doge“。这个SLF其实对于有些数据来说是可以做到优化的,因为可以认为距离较小的点可能更新的点比较多。造一组数据模拟一下这个过程(其实这个就原创 2016-07-05 11:23:32 · 1114 阅读 · 0 评论 -
bestcoder#61hdu5523Game
Problem DescriptionXY is playing a game:there are N pillar in a row,which numbered from 1 to n.Each pillar has a jewel.Now XY is standing on the S-th pillar and the exit is in the T-th pillar.XY c原创 2015-11-01 18:30:13 · 404 阅读 · 0 评论 -
CF 400 div2
从昨天周赛开始,要耍CF了~开始还害怕个人赛自己数论压根不会怎么办,发现CF全是乱搞的题orz但是就算是乱搞的也不能1A T^T犯的错误基本上都是没有把情况归类导致要么是情况想少了,要么是细节处理的不好==虽说不是算法题,质量还是不错的 贴下代码~·1.DescriptionThere always is something to choose from!原创 2015-10-31 18:34:29 · 408 阅读 · 0 评论 -
2015多校联合第五场hdu5344MZL's xor
Problem DescriptionMZL loves xor very much.Now he gets an array A.The length of A is n.He wants to know the xor of all (Ai+Aj)(1≤i,j≤n)The xor of an array B is defined as B1 xor B2...xor Bn原创 2015-09-03 10:16:21 · 465 阅读 · 0 评论 -
2015多校联合第三场5319painter
看到这个题想到之前周赛做过两遍的同样是粉刷的那个题==套啊套,依旧没找对方法 示例都不对 主要原因是这个题是斜着的orz有些点不出现在交线上怎么办?题解告诉我 我又读错题了……你什么时候能细心点??? \是红色 /是蓝色 而且是矩形不是正方形!能不能长点心???方法跟粉刷一点都不一样 呵呵对于'\',如果当前格子为红色或者绿色,前一个格子(斜线上的)既不是红色也不是绿色,则必原创 2015-09-02 17:39:34 · 507 阅读 · 0 评论 -
2015多校联合第一场hdu5288OO’s Sequence
链接‘开始有所没读明白题orz 一上午终于看懂了 已知n个数 相对顺序固定 如果存在子区间 使得任意a[i]不能整除区间里的其他数 区间长度之和是多少?借用网友的思路:每个a[i]所在范围有左右顶点分别是l[i]和r[i] 则题目转化为求(i-l[i]+1)*(r[i] - i + 1)以r[i]为例:假设最开始每枚举一个数a[i]的区间的右顶点是n即总区间最右,在第二重循环中枚举此数原创 2015-09-01 11:31:09 · 370 阅读 · 0 评论 -
2015多校联合第三场 hdu5317 RGCDQ
Problem DescriptionMr. Hdu is interested in Greatest Common Divisor (GCD). He wants to find more and more interesting things about GCD. Today He comes up with Range Greatest Common Divisor Query (原创 2015-09-02 13:40:37 · 533 阅读 · 0 评论 -
hdu5422#53-div2-1Rikka with Graph
Problem DescriptionAs we know, Rikka is poor at math. Yuta is worrying about this situation, so he gives Rikka some math tasks to practice. There is one of them:Yuta has a non-direct graph with原创 2015-08-29 21:52:55 · 583 阅读 · 0 评论 -
hdu54235423 Rikka with Tree
Problem DescriptionAs we know, Rikka is poor at math. Yuta is worrying about this situation, so he gives Rikka some math tasks to practice. There is one of them:For a tree TT, let F(T,i)F(T,i)原创 2015-08-29 22:38:52 · 574 阅读 · 0 评论 -
hdu1021Fibonacci Again找规律
Problem DescriptionThere are another kind of Fibonacci numbers: F(0) = 7, F(1) = 11, F(n) = F(n-1) + F(n-2) (n>=2). InputInput consists of a sequence of lines, each containing an i原创 2015-08-14 09:02:17 · 479 阅读 · 0 评论 -
nefu998整除问题(高精度除法)
不要思维定式==模拟手算除法即可description小明有一个比较大的数字x(1有一个数字y(1 input先输入小明的数x,再输入小红的数y; output如果两个人在一组的话输出yes,否则输出no; sample_input12 47 3#include #include#includeusing namesp原创 2015-08-01 22:40:58 · 678 阅读 · 0 评论 -
2015多校联合第二场5308I Wanna Become A 24-Point Master
Problem DescriptionRecently Rikka falls in love with an old but interesting game -- 24 points. She wants to become a master of this game, so she asks Yuta to give her some problems to practice.原创 2015-09-01 19:33:16 · 409 阅读 · 0 评论 -
2015多校联合第十场 hdu5414CRB and String字符串思维题
Problem Description CRB has two strings s and t. In each step, CRB can select arbitrary character c of s and insert any character d (d ≠ c) just after it. CRB wants to convert s to t. But is it原创 2015-08-21 23:17:56 · 583 阅读 · 0 评论 -
nefu1035数位统计
description上次哈工程校赛有一个比较有趣的问题,我们一起来探讨一下!给一个整数10,把10用二进制表示为 1010,那么10的二进制表示中有2个1那么现在的问题是这样的:给一个整数n,然后问小于n的所有数中有多少个数它们的二进制表示中有k个1。 快敲代码,动作! input 多组输入,每组两个整数n,k(原创 2015-09-21 21:33:50 · 486 阅读 · 0 评论 -
bestcoder#36-13981Strange Class字符串是否是a^n+b^n+c^n
http://weibo.com/p/230418e4ff76de0102vhll?mod=zwenzhang原创 2015-08-01 23:00:14 · 530 阅读 · 0 评论 -
弱校联萌十一大决战之背水一战C. Counting Pair
Bob hosts a party and invites N boys and M girls. He gives every boy here a unique number Ni(1 Now when Bob name a number X, if a boy and a girl wants and their numbers' sum equals to X, they can原创 2015-10-07 20:38:21 · 602 阅读 · 0 评论 -
弱校联萌十一大决战之如日中天 G Gadget Hackwrench
Input/Output: standard input/outputChip 'n' Dale rescue rangers! But observant viewers know that help is usually required by Chip and Dale themselves. Today you are in the role of cunning Gadget Hac原创 2015-10-04 20:08:18 · 805 阅读 · 0 评论 -
弱校联萌十一大决战之厉兵秣马B. Building for UN poj3566
The United Nations has decided to build a new headquarters in Saint Petersburg, Russia. It will have a form of a rectangular parallelepiped and will consist of several rectangular floors, one on top o原创 2015-10-06 09:48:57 · 569 阅读 · 0 评论 -
弱校联萌十一大决战之如日中天C Cinderella
Input/Output: standard input/outputCinderella is given a task by her Stepmother before she is allowed to go to the Ball. There are N (1 ≤ N ≤ 1000) bottles with water in the kitchen. Each bottle c原创 2015-10-04 20:01:49 · 747 阅读 · 0 评论 -
弱校联萌十一大决战之强力热身E Rectangle初中组合数学
题目啊 ~~frog has a piece of paper divided into \(n\) rows and \(m\) columns. Today, she would like to draw a rectangle whose perimeter is not greater than \(k\). There are \(8\) (out of \原创 2015-10-01 21:15:52 · 965 阅读 · 0 评论 -
2015多校联合第六场hdu5363Key Set 快速幂+yy
Problem Descriptionsoda has a set S with n integers {1,2,…,n}. A set is called key set if the sum of integers in the set is an even number. He wants to know how many nonempty subsets of S are原创 2015-09-11 07:52:03 · 423 阅读 · 0 评论 -
程序员面试金典 2.3链表 访问单个节点的删除
https://www.nowcoder.com/practice/6a668a3960e24d3ea04bba89109c6451?tpId=8&tqId=11003&tPage=1&rp=1&ru=/ta/cracking-the-coding-interview&qru=/ta/cracking-the-coding-interview/questio...原创 2018-03-20 17:19:26 · 216 阅读 · 0 评论