wss71104307
wss71104307 · 共 132 篇文章
最少拦截系统
描述 某国为了防御敌国的导弹袭击,发展出一种导弹拦截系统。但是这种导弹拦截系统有一个缺陷:虽然它的第一发炮弹能够到达任意的高度,但是以后每一发炮弹都不能超过前一发的高度。某天,雷达捕捉到敌国的导弹来袭。由于该系统还在试用阶段,所以只有一套系统,因此有可能不能拦截所有的导弹。怎么办呢?请帮助计算一下最少需要多少套拦截系统? 输入 输入若干组数据(不超过100组),每组数据一行,分别为:导弹总个数(正整数,不超过1000),导弹依此飞来的高度(雷达给出的高度数据是不大于30000的正整数,用空格分隔) 输出 对应每组数据输出拦截所有导弹最少要配备多少套这种导弹拦截系统。 样例输入 8 389 2…
2009-12-16 15:12 · 算法与数据结构 · 评论(0)
char * 与 char []
There is an important difference between these definitions: char amessage[] = "now is the time"; /* an array */ char *pmessage = "now is the time"; /* a pointer */ amessage is an array, just big enough to hold the sequence of characters and '\0' that initializes it. Individual characters within the…
2009-12-15 20:46 · C++/C · 评论(0)
Javascript PING
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>HTTP Ping</title> <style> html { height: 100%; o…
2009-12-15 13:26 · J2EE/Web开发 · 评论(0)
POJ 1004
#include <stdio.h> int main() { float f; float sum = 0; int i = 12; while(i--) { scanf("%f", &f); sum += f; } sum = sum / 12; printf("$%.2f\n", sum); return 0; }
2009-11-19 17:49 · 评论(0)
POJ 1005
#include <stdio.h> const float PI = 3.1415926; int main() { int i, N, A; scanf("%d", &N); float X, Y; for( i = 1; i <= N; i++) { scanf("%f%f", &X, &Y); A = (int)((X*X + Y*Y) * PI / 100) + 1; printf("Property %d: This property will begin eroding in year %d.\n", i, A); } printf("END OF OUTPUT.\n"); r…
2009-11-19 17:48 · 评论(0)
POJ 1003
#include <stdio.h> double a[275]; int main() { int i; for( i = 1; i < 275; i++) { a[i] = a[i - 1] + 1/(double)(i+1); } double num; scanf("%lf", &num); while(num != 0.00) { for( i = 1; i < 274; i++) { if(a[i-1] <= num && a[i] > num) { printf("%d card(s)\n", i); break; } } scanf("%lf", &num); } retur…
2009-11-18 15:58 · 评论(0)
POJ 1491
#include <stdio.h> #include <stdlib.h> #include <math.h> void swap(int &a, int &b) { int c = a; a = b; b = c; } int gcd(int a, int b) { if(a < b) swap(a, b); if(a % b == 0) return b; else return gcd(b, a%b); } int main() { int n; int i, j, count; scanf("%d", &n); while( n !=0) { count = 0; int * da…
2009-11-10 15:27 · 评论(0)
POJ 1353
#include <stdio.h> #include <string.h> #include <stdlib.h> int main() { int n, m, k; int i,j; while(scanf("%d,%d,%d", &n, &m, &k) == 3) { char * src = (char *)malloc(n); char * dest = (char *)malloc(n); memset(src,'w', m); memset(src + m, 'b', n-m); for(i = 0; i < k; i++) { for(j = 0; j < n; j++) {…
2009-11-09 14:57 · 评论(0)
POJ1002
#include <iostream> #include <string> using namespace std; int myctoi(const char c); int a[10000000]; int main() { int N; cin>>N; string str; int num; while(N--) { num = 0; cin>>str; for(int i = 0; i < str.length(); i++) { if(str.at(i) != '-') num = num * 10 + myctoi(str.at(i)); } a[num]++; } num =…
2009-11-06 15:14 · ACM/Topcoder · 评论(0)
POJ 1218
#include <iostream> using namespace std; int cells[101]; int main() { int N; cin>>N; int n, answer; while(N--) { cin>>n; for(int i = 2; i <= n; i++) for(int j = 2; j <= n; j++) { if(j % i == 0) cells[j] = 1 - cells[j]; } answer = 0; for(int i = 1; i <= n; i++) { if(cells[i] == 0) answer++; cells[i]…
2009-11-05 18:28 · 评论(0)
test
1 .file "test.c" 2 .section .rodata 3 .LC0: 4 .string "address of i = %u\n" 5 .LC1: 6 .string "input please" 7 .LC2: 8 .string "%d" 9 .LC3: 10 .string "%d\n" 11 .text 12 .globl main 13 .type main, @function 14 main: 15 leal 4(%esp), %ecx 16 andl $-16, %esp 17 pushl -4(%ecx) 18 pushl %ebp 19 movl %e…
2009-10-12 23:17 · 评论(0)
总结: 提高网站访问速度
Best Practices for Speeding Up Your Web Site 原文: http://developer.yahoo.com/performance/rules.html#page-nav 优化网站性能 提高网站速度访问速度的14条实践 http://www.phpv.net/html/1660.html Minimize HTTP Requests 减少HTTP请求次数 80/20法则: http://yuiblog.com/blog/2006/11/28/performance-research-part-1/ 当浏览一个页面的时候,浏览器花费80%的时间在获取…
2009-09-20 17:15 · J2EE/Web开发 · 评论(0)
Divie into Python 读书笔记 第三章
List 1.list [] 定义 2.List有负索引,list[-k]=lisk[n-k] 3.list的切片slice li[m,n],从m到n(不包括) 3.1 m到n没有区间,返回空的list 3.2 list[:n] 返回从o到n的list 3.3 list[n:] 返回n后面所有的list 4 4.1 list.append() 向list添加元素 4.2 list.insert(index, "new") 向list指定位置插入新元素 4.3 list.extend() 连接2个list *** append 和 extend的区别: append如果添加的是list的话,l…
2009-08-25 22:26 · Python · 评论(0)
如何用加1操作实现减法
转载自 http://www.matrix67.com/blog/archives/944/trackback 设想这样一个计算机系统,它只支持以下几个操作: 1. 定义变量、给变量赋值; 2. 变量自身加一; 3. 令一段语句循环执行指定的次数。 这个系统只处理且只能处理0和正整数。系统不存在“溢出”的问题。 注意这个系统没有比较运算,事实上它甚至不存在Boolean值和判断语句。 循环语句也不是FOR i=a TO b DO的形式,只能是LOOP n的形式。 在这个系统上实现加法很容易,让a自增b次即可。现在的问题是,你能在这个系统上实现减法吗? 问题的关键在于如何实现自减一操作。 本来…
2009-08-17 10:16 · 算法与数据结构 · 评论(0)