分类目录归档:程序相关

C,Python,环境配置等

HTTP_REFERER有效和无效的情况

HTTP_REFERER有效和无效的情况

【准备】
test.php文件

echo $_SERVER['HTTP_REFERER'];

【有效的情况】
1、以iframe 形式调用地址,如下所示

2、以window.open调用,打开新页面
window.open(url);

3、使用window.location.replace在Firefox 和Chrome下可以获取HTTP_REFERER

window.location.replace(url);

4、使用window.location.href在Firefox 和Chrome下可以获取HTTP_REFERER
window.location.href = url;

5、使用A标签跳转可以获取HTTP_REFERER

【无效的情况】
1、使用函数 file_get_contents或file等函数调用URL地址,这个地址所在的文件无法获取HTTP_REFERER

2、使用window.location.replace在IE6、IE7、IE8下无法获取HTTP_REFERER
window.location.replace(url);

3、使用window.location.href在IE6、IE7、IE8下无法获取HTTP_REFERER
window.location.href = url;

4-Hanoi-Tower

问题描述
【描述 Description】
“汉诺塔”,是一个众所周知的古老游戏。现在我们把问题稍微改变一下:如果一共有4根柱子, 而不是3根,那么至少需要移动盘子多少次,才能把所有的盘子从第1根柱子移动到第4根柱子上呢?

为了编程方便,您只需要输出这个结果mod 10000的值。

【输入格式 Input Format】
一个正整数n。(0

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <stdio.h>
int main()
{
       int n, m, s, t, i, j, flag;
       scanf("%d", &n);
 
       m = 1;
       s = 1;
       t = 2;
       flag = 0;
 
       for (i = 2; i <= n; i++)
       {
              if (flag == 1)
                     break;
 
              for (j = 1; j <= i; j++)
              {
                     s = (s + t) % 10000;
                     m++;
 
                     if (m == n)
                     {
                            printf("%d\n", s);
                            flag = 1;
                            break;
                     }
              }
              t = (t * 2) % 10000;
       }
       return 0;
}