给定一个数组A,其中有一个位置被称为Magic Index,含义是:如果i是Magic Index,则A[i] = i。假设A中的元素递增有序、且不重复,请给出方法,找到这个Magic
Index。更进一步,当A中允许有重复的元素,该怎么办呢?
没有重复元素的情况
一些同学在遇到这个题目的时候,往往会觉得比较简单。扫描一遍,不就ok了么?O(n)的。很简单呀。可是,大家要注意到...
分类:
其他好文 时间:
2014-07-16 16:23:25
阅读次数:
272
Problem Description
Due to recent rains, water has pooled in various places in Farmer John's field, which is represented by a rectangle of N x M (1 <= N <= 100; 1 <= M <= 100) squares. Each square...
分类:
其他好文 时间:
2014-07-16 08:01:44
阅读次数:
291
E. A Magic LampTime Limit:1000msCase Time Limit:1000msMemory Limit:32768KB64-bit integer IO format:%I64d Java class name:MainKiki likes traveling. One...
分类:
其他好文 时间:
2014-07-14 23:52:41
阅读次数:
352
1、这个函数的使用和php.ini中的magic_quotes_gpc的配置有关,默认情况下,这个配置为on。并且,这个配置处于一个较高级别,脚本中不能修改。所以,检测这个配置情况就很重要。2、在脚本中,虽然不能配置magic_quotes_gpc,但可用get_magic_quotes_gpc()...
分类:
Web程序 时间:
2014-07-12 14:35:22
阅读次数:
311
Description
Magic Numbers
Write a program that finds and displays all pairs ofintegers and
such that:
neither nor
have any digits repeated; and , where
N is a given i...
分类:
其他好文 时间:
2014-07-10 20:10:06
阅读次数:
238
Problem D
Prince and Princess
Input: Standard Input
Output: Standard Output
Time Limit: 3 Seconds
In an n x n chessboard, Prince and Princess plays a game. The squares in the chessboard are ...
分类:
其他好文 时间:
2014-07-09 11:44:54
阅读次数:
211
前言在mysql中,用于转义的函数有addslashes,mysql_real_escape_string,mysql_escape_string等,还有一种情况是magic_quote_gpc,不过高版本的PHP将去除这个特性。首先,宽字节注入与HTML页面编码是无关的,笔者曾经看到就放弃了尝试,...
分类:
其他好文 时间:
2014-07-09 00:13:58
阅读次数:
238
题意:著名的魔术师大卫科波菲尔喜欢表演下面的魔术:一个N行N列不同图片的矩阵出现在大屏幕上,我们给所有的图片这样命名:
每一个参与的观众被要求将手指放在左上方的图片上(即编号为1的图片),魔术师开始了:魔术师告诉观众在图片上移动k次(移动是把手指放到上下左右相邻的图片上,如果那儿有图片的话),然后他(魔术师)的手微微一指(指向一些图片)并说:“你不在这里”,然后……是真的!你的手指...
分类:
其他好文 时间:
2014-07-08 21:08:14
阅读次数:
151
Magic xpa最新版本Magic xpa 2.4c 截止日期2014-07-05
分类:
其他好文 时间:
2014-07-05 22:30:54
阅读次数:
292
题意:
a[i] ^ x = f[i] ( i = 1...8 ) 和 ( a[1] + a[2] + ... + a[8] ) ^ x = f[9] 现在f为已知 求x
思路:
从低位到高位确定x值 做法见注释
代码:
#include
#include
#include
using namespace std;
int f[20],t,ans;
int mai...
分类:
其他好文 时间:
2014-07-04 07:22:41
阅读次数:
241