hdu 5500 Reorder the Books(规律)】的更多相关文章

http://acm.hdu.edu.cn/showproblem.php?pid=5500 Reorder the Books Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 942    Accepted Submission(s): 519 Problem Description dxy has a collection of…
Reorder the Books Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5500 Description dxy家收藏了一套书,这套书叫<SDOI故事集>,<SDOI故事集>有n(n≤19)n(n\leq 19)n(n≤19)本,每本书有一个编号,从111号到nnn号. dxy把这些书按编号从小到大,从上往下摞成一摞.dxy对这套书极其重视,不允许…
题意:   有一个1→n的排列形成的数列,我们要用最少的操作次数把这个数列从小到大排序,每次操作都是把一个数放到整个数列的最前面. 思路:        首先最大的数n是不用操作的(其他数操作好了,n自然在最后面了).先找到数n的位置,在n之前找n-1,若没找到n-1,则n-1需要操作,所有小于n-1的数均需要操作:若找到了n-1,再接着往前依次找n-2,n-3,...假如数k找不到了,那就是至少需要k次操作. 复杂度O(n). #pragma comment(linker, "/STACK:1…
题意: 有n本书,编号为1~n,现在书的顺序乱了,要求恢复成有序的样子,每次只能抽出其中一本并插到最前面,问最少需要多少抽几次? 思路: 如果pos[i]放的不是书i的话,则书i的右边所有的书都必须抽出来.抽出来的书必定可以回到它最终的位置上,即每本书最多抽出来1次,可以想象抽出来后直接扔掉,在剩下的书中找到一个有序,且最后一个元素为n,且等差为1的序列{...n-2,n-1,n}. //#include <bits/stdc++.h> #include <iostream> #i…
Reorder the Books Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 919    Accepted Submission(s): 501 Problem Description dxy has a collection of a series of books called "The Stories of SDOI&q…
Problem Description dxy has a collection of a series of books called “The Stories of SDOI”,There are n(n≤19) books in this series.Every book has a number from 1 to n. dxy puts these books in a book stack with the order of their numbers increasing fro…
Reorder the Books Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 179    Accepted Submission(s): 125 Problem Description dxy has a collection of a series of books called "The Stories of SDOI&q…
http://acm.hdu.edu.cn/showproblem.php?pid=5500 Reorder the Books Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 920    Accepted Submission(s): 502 Problem Description dxy has a collection of…
Reorder the Books 问题描述 dxy家收藏了一套书,这套书叫<SDOI故事集>,<SDOI故事集>有n(n\leq 19)n(n≤19)本,每本书有一个编号,从11号到nn号. dxy把这些书按编号从小到大,从上往下摞成一摞.dxy对这套书极其重视,不允许任何人动这套书. 有一天Evensgn到dxy家玩,dxy因为和妹子有约会,就让Evensgn自己待在他家.Evensgn对这套书非常好奇,偷偷的看了一下,结果发现这里面竟然有当年小E和小Q的故事.Evensgn看…
http://acm.hdu.edu.cn/showproblem.php?pid=4722 [题意]: 找GoodNumbers一个数N,如果它每一个位数字之和可以整除10,那么它就是GoodNumbers,比如451就是一个4+5+1=10,求[A,B]之间这样的数的个数 [题解]: 先写一个暴力代码用来找规律 发现: 0-10    1 0-100  10 0-1000   100 0-990  99 0-992  100 0-997   100 基本规律为 n/10 + (1或0) 加1…