- 博客(44)
- 资源 (4)
- 收藏
- 关注
原创 sicily 1752
#include "iostream"#include "cmath"#include "map"using namespace std;bool is_primer(int n){ if (n == 1) return false; int m = floor(sqrt(double (n)) + 0.5); for (int i = 2; i <= m
2011-11-30 15:54:25 433
原创 sicily 1765
#include "iostream"#include "string"#include "algorithm"#include "cmath"using namespace std;bool is_primer(int n)//判断是否为质数{ if (n == 1) return false; int m = floor(sqrt(double (n)) +
2011-11-30 10:35:17 422
原创 sicily 1757
#include "iostream"#include "string"#include "cctype"#include "sstream"using namespace std;int main(){ int T; cin >> T; while (T--) { string str[5];//保存输入的字符串 int a[5] = {0
2011-11-30 10:01:55 1003
原创 sicily 1753
#include "iostream"#include "cctype"#include "string"#include "sstream"using namespace std;int main(){ string str; while (cin >> str && str != "XXX") { int size; size = str.s
2011-11-30 00:32:18 435
原创 sicily 1931
//利用两个队列就可以解决问题,一个出队,一个入队!//但是就开始的时候我没有考虑到当输入的牌数小于或等于2的情况,所以WA了一次!#include "iostream"#include "deque"using namespace std;int main(){ int TestCase; cin >> TestCase; while (TestCase-
2011-11-29 13:14:05 570
原创 sicily 1926
class NumCal { int *p; // 数组首地址 int size; // 数组sizepublic: int sum(); // 计算数组元素和 NumCal(); // 构造函数 NumCal(int *new_p, int new_size); // 构造函数};int NumCal::sum(){
2011-11-29 12:51:02 435
原创 sicily 1176
#include "iostream"#include "memory.h"using namespace std;int Num[1010];//存储输入的数字int ans[1010][1010];//对每一次决策后结果的存储!int dp(int a, int b);//动态规划方法的实现int main(){ int n, count = 0;
2011-11-29 12:39:31 1090
原创 sicily 1623
#include "iostream"using namespace std;int main(){ int TestCase; cin >> TestCase; int k; for (k = 0; k < TestCase; k++) { int a, b; cin >> a >> b; if (a > b) { int te
2011-11-26 12:55:41 404
原创 sicily 1795
#include "iostream"using namespace std;struct Coordinate//击球坐标信息{ int x; int y;};int main(){ int TestCase; cin >> TestCase; while (TestCase--) { int HitNum, sum = 0;
2011-11-25 16:01:11 438
原创 sicily 1798
//在看题的时候,我以为这是一道好复杂的问题,也让我思考了半天!原来是一道非常简单的问题!//下面的做法是在思考了半天之后的突发其想而做出来的!终于让我明白了“复杂的问题简单化,而简单的问题复杂化”这句话了!呵呵!#include "iostream"using namespace std;int main(){ int n; while (cin >> n && n)
2011-11-25 12:28:35 694
原创 sicily 1426
//第一次由于用了两层循环,所以超时了!原来我没有用到排序出来的结果,//在排序出来的结果上用一个层循环就可以解决了超时的问题!#include "iostream"#include "string"#include "algorithm"using namespace std;int main(){ int TestCase; cin >> TestCas
2011-11-24 18:20:23 545
原创 sicily 1500
#include "iostream"#include "cmath"using namespace std;bool is_primer (int n)//判断是否为素数!{ if (n == 1) return 0; int m; m = floor(sqrt(double (n)) + 0.5); for (int i = 2; i <= m; i+
2011-11-23 12:48:15 568
原创 sicily 1438
#include "iostream"#include "algorithm"using namespace std;bool comp(int a, int b){ return a > b;}int main(){ int TestCase; cin >> TestCase; while (TestCase--) {
2011-11-22 23:52:17 618
原创 sicily 1482
//就开始的时候在格式的输出有错误,实在是搞不懂“两个相邻测试数据间用一个空行隔开”如何表示,看了别人的代码才明白!#include "iostream"#include "algorithm"using namespace std;struct Info//学生信息的存储{ int num; int chinese; int math; int engli
2011-11-21 23:52:30 564
原创 sicily 1433
#include "iostream"#include "algorithm"using namespace std;int main(){ int TestCase; cin >> TestCase; while (TestCase--) { int StoreNum, distance = 0; cin >> StoreNum; int *po
2011-11-21 22:11:19 670
原创 sicily 1561
#include "iostream"#include "cmath"using namespace std;bool is_primer(int n){ if (n == 1) return false; int b = floor(sqrt(double(n))+0.5); for (int i = 2; i <= b; i++) if (n % i
2011-11-21 17:00:54 674
原创 sicily 1510
#include "iostream"#include "string"using namespace std;struct Info{ int pos; string str;};int main(){ int N; cin >> N; Info *s = new Info[N]; for (int i = 0; i < N; i++)
2011-11-21 12:43:29 450
原创 sicily 1443
#include "iostream"#include "deque"using namespace std;struct Info//job的位置和优先权的信息{ int num; int pr;};int main(){ int n; cin >> n; deque d; while (n--) { d.clear();
2011-11-21 10:22:20 1002
原创 sicily 1006
//就开始的时候读不懂题目,感觉就是简单的排列就可以,但是参考了别人的才清楚,原来是要求字符串ABCDE的所有排列//与题目给出的排列进行比较,找出间距最小的差距值!用到stl中的next_permutation()函数就简单好多了!#include "iostream"#include "string"#include "map"#include "algorithm"u
2011-11-17 20:00:07 1424
转载 stl算法:next_permutation剖析 .
在标准库算法中,next_permutation应用在数列操作上比较广泛.这个函数可以计算一组数据的全排列.但是怎么用,原理如何,我做了简单的剖析.首先查看stl中相关信息.函数原型:template bool next_permutation( BidirectionalIterator _First, BidirectionalIterato
2011-11-17 12:44:44 561
原创 sicily 1209
#include "iostream"using namespace std;int main(){ int N; cin >> N; for (int i = 1; i <= N; i++) { int n, m; cin >> n >> m; int count = 0; for (int j = 2; j*(1+j) <= m * 2; j
2011-11-15 20:52:34 572
原创 sicily 1021
#include "iostream"#include "stack"#include "map"using namespace std;int main(){ int N; while (cin >> N && N != 0) { map m; stack s; int pos1, pos2; for (int i = 0; i < N
2011-11-15 20:51:35 815
转载 康托展开公式
康托展开:X=an*(n-1)!+an-1*(n-2)!+...+ai*(i-1)!+...+a2*1!+a1*0!ai为整数,并且0 应用实例:{1,2,3,4,...,n}的排列总共有n!种,将它们从小到大排序,怎样知道其中一种排列是有序序列中的第几个?如 {1,2,3} 按从小到大排列一共6个:123 132 213 231 312 321。想知道321是{1,2,3
2011-11-15 09:21:02 1720
原创 sicily 1198
#include "iostream"#include "string"#include "algorithm"using namespace std;bool comp(string s1, string s2){ return s1 + s2 < s2 + s1;//这样的比较就可以避免c,ca这种情况的出现判断!输出的是cac,而不是cca!}int main
2011-11-12 00:43:51 851
原创 sicily 1240
//利用最原始,最容易懂的方法:通过计算出加多的路程,然后将显示的路程减去加多的路程就得到实际的路程!其过程利用到递推的关系!#include "iostream"using namespace std;int main(){ int n; while (cin >> n && n != 0) { int temp1 = n, temp2 = n, count =
2011-11-10 19:18:06 809
原创 sicily 1342 (0/1背包问题)
//首次接触背包问题,理解起来还是有点吃力!需要多练习! #include "iostream"#include "cmath"using namespace std;int total[26][300010];int main(){ int N, m; while (cin >> N >> m) { int *price = new int[m+1];
2011-11-10 00:04:29 578
转载 0/1背包问题
转载自http://hi.bccn.net/space-339919-do-blog-id-14722.html动态规划是用空间换时间的一种方法的抽象。其关键是发现子问题和记录其结果。然后利用这些结果减轻运算量。比如01背包问题。/* 一个旅行者有一个最多能用M公斤的背包,现在有N件物品,它们的重量分别是W1,W2,...,Wn,它们的价值分别为P1
2011-11-09 20:12:02 502
原创 sicily 1341
//while(1)//{//cin >> n;//}//和//while(cin >> n)//{//}//的区别很重要,时间有很大的差距!#include "iostream"#include "set"using namespace std;int main(){ int N; while (cin >> N) { set
2011-11-09 00:05:47 508
原创 sicily 1306
#include "iostream"#include "set"#include "algorithm"using namespace std;int main(){ int n, m; /*multiset s; multiset::iterator it;*/ while (cin >> n >> m && m != 0 && n != 0) {
2011-11-08 21:28:58 530
原创 sicily 1259
#include "iostream"#include "math.h"#include "vector"using namespace std;int is_prime(int x);//判断一个数是否为素数int main(){ int ans, count = 0; vector v;//用一个容器来装素数 while (cin >> ans && ans
2011-11-08 19:53:35 721
原创 sicily 1325
//这一题如果逐一枚举,就会超时!所以需要对一些不符合情况的数进行删除!#include "iostream"#include "math.h"using namespace std;int main(){ int T; cin >> T; int *a = new int[T]; for (int i = 0; i < T; i++) { cin >
2011-11-08 13:41:30 793
原创 sicily 1388
#include "iostream"#include "map"#include "string"using namespace std;int main(){ map m;//定义一个map容器 m[' '] = 0; m['A'] = 1; m['B'] = 2; m['C'] = 3; m['D'] = 4; m['E'] = 5; m['F'] = 6; m[
2011-11-08 00:06:23 500
原创 sicily 1294
//一道公式题目,如果不懂公式,很难做!公式:(a*b) mod c=a*(b mod c) mod c #include using namespace std; int main() //两次求余数就可以!{ int a, b, c; cin >> a >> b >> c; int s = a % c; for(int i
2011-11-07 19:41:39 553
转载 大数四则运算的C++实现
大数四则运算的C++实现[摘要] 大数运算不仅仅运用在密码学中,还运用在一些物理学研究、生物学,化学等科目中。大数运算,意味着参加的值和计算结果通常是以上百位数,上千位数以及更大长度之间的整数运算。例如大家所熟知圆周率π的值,在一般的数值计算中用到圆周率的不须要多大的精度,但在计算一些星球或是星系上的体积面积时便显的误差很大了,这就要求π值计算的精度达到几百万位甚至更高,才能缩小误
2011-11-07 12:49:09 17269 6
原创 sicily 1232
//这一道水题,主要是读懂题意:移动式插座需要有电力供应才可以工作!(即是一个插座需要插在其他的插座上才可以工作)#include "iostream"using namespace std;int main(){ int K, N; cin >> N; while (N--) { cin >> K; int *a = new int[K]; fo
2011-11-07 09:19:14 578
原创 sicily 1200
#include "iostream"#include "set"using namespace std;int main(){ int n; while (cin >> n && n != 0) { int *a = new int[n]; for (int i = 0; i < n; i++) cin >> a[i]; multiset m
2011-11-07 08:59:51 556
原创 sicily 1293
#include "iostream"using namespace std;int main(){ int i, j, m = 0, q; cin >> i >> j; int *sum = new int[j]; for (int n = 0; n < j; n++) sum[n] = 1;//数组存放链的长度 while (i <= j) {
2011-11-07 00:01:11 480 1
原创 sicily 1324
#include "iostream"#include "string"using namespace std;int main(){ int T; cin >> T; string *str = new string[T]; for (int i = 0; i < T; i++)//字符串的输入 cin >> str[i]; for (int i = 0
2011-11-06 23:00:07 466
原创 sicily 1014
#include "iostream"using namespace std;int main(){ int n = 2992; do { int sum1 = 0, sum2 = 0, sum3 = 0; sum1 = n % 10 + n / 10 % 10 + n / 100 % 10 + n / 1000;//十进制数的相加和 int m = n;
2011-11-06 21:21:22 501
原创 sicilly 1147
#include "iostream"#include "string"using namespace std;struct Info//一个结构体存储学生的信息{ string name; int score1, score2, num, scholarship; char ch1, ch2;};int main(){ int n; cin
2011-11-06 10:53:25 526
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人