上一页 1 ··· 178 179 180 181 182
摘要: 字符串处理简单题,注意reverse()的使用,这个函数要包含"algorithm" 阅读全文
posted @ 2011-02-01 12:46 undefined2024 阅读(238) 评论(0) 推荐(0)
摘要: 题意:给定三个矩阵a,b,c,问a×b是否等于c?分析:只需要设置一个列向量x,求a*(b*x),求c*x,看是否相等即可。当然这不能保证正确,x是生成的随机向量,多次生成多次测试即可使错误概率大大减小。#include <iostream>#include <cstdio>#include <cstring>#include <cstdlib>#include <ctime>#include <algorithm>using namespace std;const int maxn = 510;long lon 阅读全文
posted @ 2011-02-01 12:45 undefined2024 阅读(712) 评论(0) 推荐(0)
摘要: 树状数组题意:给定一棵树,某些节点上有苹果,多次询问各子树上的节点数,并且在询问的中途随时可能新增和删除苹果。分析:dfs遍历树的同时,对每个点标注时间,每个点有一个开始时间和一个结束时间,把这两个时间当做下标,该点的苹果个数(1或0)填入数组的两个对应位。子树中结点的时间段一定是根节点时间段的子段,所以求子树苹果数,只需求数组某区间的和即可。用树状数组比较快。#include <iostream>#include <cstdio>#include <cstring>#include <cstdlib>using namespace std;#d 阅读全文
posted @ 2011-02-01 12:44 undefined2024 阅读(2466) 评论(0) 推荐(0)
摘要: 水题,求平均数#include <stdio.h>int main(){ //freopen("D:\\t.txt", "r", stdin); int n; while (scanf("%d", &n) != EOF && n != 0) { int i; int xmin, xmax, sum; scanf("%d", &xmin); xmax = xmin; sum = xmin; for (i = 1; i < n; i++) { int a; scanf( 阅读全文
posted @ 2011-02-01 12:38 undefined2024 阅读(272) 评论(0) 推荐(0)
上一页 1 ··· 178 179 180 181 182