自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

西西里的美丽传说

Keep moving......

  • 博客(43)
  • 收藏
  • 关注

原创 常见网络词汇

以太网以太网是一种流行的分组交换局域网技术,现在几乎所有公司和个人的网络都采用以太网。最初的布线方式是用同轴电缆连接所有的计算机,这种方式已被取代了,现在的方式称为双绞线以太网,允许计算机使用普通的非屏蔽铜线接入以太网。以太网被设计称为一种支持广播的共享总线技术,由于所有网点连接到一个共享的单一通信信道,这种拓扑方式称为共享总线。由于所有网点能收到每次传输的数据,因此可把一个分组同时传输到

2011-12-13 21:34:08 1010

转载 c++ 虚函数 构造函数 析构函数

一、虚函数和构造函数        当创建一个含有虚函数的对像是,必须初始化它的VPTR以指向相应的VTABLE,这必须在对虚函数进行任何调用之前完成,而设置VPTR这项工作是由构造函数来完成。编译器在构造函数的开头部分秘密地插入能初始化VPTR的代码,如果我们没有为一个类显式创建构造函数,则编译器会为我们生成构造函数。如果该类含有虚函数,则生成的构造函数将会包含相应的VPTR初始化代码。

2011-11-16 23:25:11 780

转载 c++ 纯虚函数

一、抽象基类和纯虚函数         在设计时,常常希望基类仅仅作为其派生类的一个接口,也就是说,仅想对基类进行向上类型转换,使用它的接口,而不希望用户创建一个基类的对象。要做到这一点,可以在基类中加入至少一个纯虚函数,来使基类成为抽象类,如果某人试着生成一个抽象类的对象,编译器会制止他。另外,当继承一个抽象类时,必须实现所有的纯虚函数,否则继承出的类也将是抽象类。         建立

2011-11-16 21:50:34 2714

转载 c++ 虚函数

一、动态捆绑与虚函数      把函数体与函数调用相联系称为捆绑,当捆绑在程序允许之前(由编译器和连接器)完成时,这称为早捆绑。而在运行时根据对象的类型进行的捆绑被称为晚捆绑,又称为动态捆绑,或运行时捆绑。当一个语言实现晚捆绑时,必须有某种机制来确定运行时对象的类型并调用合适的成员函数,对于一种编译语言,编译器并不知道实际的对象模型,但它插入能找到和调用正确函数体的代码。       对于

2011-11-15 21:47:03 538

转载 c++ 继承和组合

构造函数的初始化列表        当创建一个对象时,编译器总是确保调用了所有的子对象的构造函数,如果子对象有自己的默认构造函数,那么编译器可以自动地调用它们。但是,如果子对象没有默认构造函数,或者想改变构造函数的某个默认参数,这就会出现问题,因为这个新类的构造函数没有权利访问这个子对象的私有数据成员,所有不能直接对它们初始化。解决的方法就是:构造函数初始化列表。        MyT

2011-11-15 20:57:54 663

转载 派生类对象初始化构造过程顺序

#include using namespace std;class A { private: int a; public: A(int x):a(x) { cout <<a <<" "; } };class B: A

2011-10-12 21:34:06 2319

转载 C++#define的用法(含特殊)

1 无参宏定义无参宏的宏名后不带参数。其定义的一般形式为:    #define 标识符 字符串其中的“#”表示这是一条预处理命令。凡是以“#”开头的均为预处理命令。“define”为宏定义命令。“标识符”为所定义的宏名。“字符串”可以是常数、表达式、格式串等。在前面介绍过的符号常量的定义就是一种无参宏定义。此外,常对程序中反复使用的表达式进行宏定义。例如:    #d

2011-08-26 10:06:43 4340

转载 SVC——可分层视频编解码

SVC,即Scaled Video Coding,可分层视频编解码,是一种能将视频流分割为多个分辨率、质量和帧速率层的技术,是对当今大多数视频会议设备所采用的H.264视频编解码标 准的扩展。视频会议设备采用SVC技术来收发由一个小的基极层和多个可提高分辨率、帧速率和质量的其它可

2011-08-25 00:11:11 4660 1

原创 sicily 2002 Feeding Time

#include #include #include using namespace std;int row,col;int vis[1000][1000],farm[1000][1000];int dir[8][2] = { {-1,0},{-1,1},{0,1},{1,1},{1,0},{1,-1},{0,-1},{-1,-1} };//移动的方向struct

2011-06-18 16:14:00 871

原创 sicily 1150 简单魔板

//这里用到的方法很暴力,就是直接的BFS;//仅能过1150而已,就当做练习下BFS啦// source code of submission 804105, Zhongshan University Online Judge System#include #include #include using namespace std;struct status

2011-06-14 14:15:00 3391 1

原创 sicily 1153 马的周游问题

解法一: // source code of submission 799182, Zhongshan University Online Judge System#include #include #include #include using namespace std;int dir[8][2] = {-2,1,-1,2,1,2,2,1,2,-1,1,-2

2011-06-11 20:52:00 1067

原创 sicily 1152 简单的马周游问题

解法一:// source code of submission 799172, Zhongshan University Online Judge System#include #include #include #include using namespace std;int dir[8][2] = {-2,1,-1,2,1,2,2,1,2,-1,1,-2,-1

2011-06-11 20:49:00 1217

原创 sicily 1172 Queens, Knights and Pawns

<br />#include <iostream>#include <cstdio>#include <cstring>using namespace std;struct node { int vis; int has; } board[1200][1200];int Q[120][2],K[120][2],P[120][2];int main(){ int row,col,q_num,k_num,p_num,i,j,k,Case = 1;

2011-06-02 11:45:00 821

原创 sicily 1099 Packing Passengers

<br /> //t的值要使得costA * x + costB * y 最小,如果有多个值,则取令x最大的t //上式子可以改写成(x+(capB/gcd)*t)*costA+(y-(capA/gcd)*t)*costB ==> ((costA*capB-capA*costB)*t)/gcd + capA * x + capB*y////于是,当costA*capB-capA*costB<0,t应取最大值; 当costA*capB-capA*costB>0,t应取最小值;//当costA*ca

2011-06-01 16:14:00 962

原创 sicily 1231 The Embarrassed Cryptography

这道题主要用到了一个筛法求素数,大数的模运算,以及暴力搜索的方法.....题意比较简单,关键要注意到大数的模运算问题!// source code of submission 784557, Zhongshan University Online Judge System#include #include #include using namespace std;int prime(int a[],int n) //筛法求n以内的素数{ int

2011-05-31 23:33:00 1577

原创 关于同余与模运算的总结

    123456789*987654321 = ()A: 121932631112635266                                       B: 121932621112635267C: 121932631112635268                                       D: 121932631112635269解答: 利用公式(ab)mod n  = (a mod n)(b mod n)mod n,可以得到        123456789

2011-05-31 21:55:00 8183

原创 sicily 1021 couples

<br />// source code of submission 781937, Zhongshan University Online Judge System#include <iostream>#include <cstring>#include <stack>using namespace std;int couple[200020];int main(){ int n,i,a,b; while(cin>>n,n) {

2011-05-31 20:58:00 1565 1

原创 sicily 1020 Big Integer

这里要利用到公式:(a+b) mod (n) = (a mod n) + (b mod n) mod (n);把大整数写成自左向右的形式:1234 = ((1*10+2)*10+3)*10+4,然后利用前面这个公式,每步取模,算法如下:#include #include using namespace std;int main(){ int test,n,i,k,ans,temp; int bas[106],res[106]; char oper[600];

2011-05-31 20:56:00 1369

原创 sicily 1206. Stacking Cylinders

<br />解题思路:<br />(学习了别人的方法,原文地址http://hi.baidu.com/watermoon_littlegui/blog/item/ce42cfecd2c20edcb21cb1d6.html):<br />同一层每相邻两个可求出上一层的其中一个<br /> 直到只剩下一个即是最顶层的那个<br /> 知道两点坐标和三边长度(其中两边相等),求第三点的坐标。<br /> 如图:<br />已知A、B点坐标以及AC=BC=2,求C点的坐标。 <br /> <br />作辅助线AD垂

2011-05-21 19:00:00 1387

原创 sicily 1035 DNA matching

//刚开始误以为输入的链长都是相同的,导致WA了半天,郁闷!//也正因为输入的链长是不一致的,所以对于输入我们用动态处理的方式去处理,而不是全部输入后再统计#include #include #include using namespace std;int main(){ int test,n,i,ix; cin>>test; while(test--) { cin>>n; int count = 0; set Set; for(i =

2011-05-20 21:09:00 1535

原创 sicily 1780 Faulty Odometer Again

<br />// source code of submission 766858, Zhongshan University Online Judge System#include <cstdio>#include <cstring>int change(int a){ if(a==3||a==4) return a-1; else if(a==6||a==7) return a-2; else if(a==9)

2011-05-17 10:28:00 747

原创 sicily 1240 Faulty Odometer

<br />// source code of submission 766843, Zhongshan University Online Judge System//把一个9进制数转换成10进制//不过这个9进制数的数字是0 1 2 3 5 6 7 8 9,就是没有4;//把大于4的数都-1,然后就是真正的9进制数//因此把数字转成标准9进制,再转成10进制就OK了#include <cstdio>#include <cstring>int main(){

2011-05-17 10:27:00 971

原创 sicily 1177 Take Your Vitamins

<br />感觉题目蛮无聊的....<br /> <br />// source code of submission 767064, Zhongshan University Online Judge System#include <iostream>#include <cstdio>#include <cstdlib>#include <string>using namespace std;struct node{ float a,r,ratio; s

2011-05-17 10:24:00 568

原创 sicily 2382 Flowers Flourish from France

<br />// source code of submission 744571, Zhongshan University Online Judge System#include <iostream>#include <string>#include <vector>#include <cctype>using namespace std;int main(){ string s,sub_str; int mark,flag,i; while

2011-05-16 13:03:00 629

原创 sicily 2401 Judges' Time Calculation

<br />// source code of submission 757803, Zhongshan University Online Judge System#include <iostream>using namespace std;int main(){ int H,M,SH,SM,DH,DM,EH,EM; int n,i,cnt; cin>>n; while(n--) { cin>>SH>>SM>>DH>>

2011-05-16 13:00:00 454

原创 sicily 1201 01000001

<br />// source code of submission 757941, Zhongshan University Online Judge System#include <iostream>#include <cstring>#include <cstdio>#include <malloc.h>void add(char a[],char b[],char back[]){ int i,j,k,up,x,y,z,l; char *c; i

2011-05-16 12:58:00 943

原创 sicily 1122 Prerequisites?

<br />solution 1:<br /> <br />// source code of submission 765531, Zhongshan University Online Judge System#include <iostream>#include <vector>#include <algorithm>using namespace std;int main(){ int k,m,i,j,cour_num,flag; //co

2011-05-16 12:52:00 491

原创 sicily 1783 Large is Better

题目不难,但是有些细节还是要注意的.....很容易wrong answer,如果你碰到WA,试试123012400198和1234这两个测试用例吧! // source code of submission 766632, Zhongshan University Online Judge System#include #include #include using namespa

2011-05-16 12:47:00 1178 2

原创 sicily 1818 成绩转换

<br />//刚开始用结构体数组做的,超时了...这个程序是参考别人的,不是本人原创。//就当做是学习下map的用法吧!哎,觉得自己太水了....// source code of submission 764202, Zhongshan University Online Judge System#include<iostream>#include<string>#include<map>using namespace std;void print(int n){

2011-05-13 12:52:00 1156

原创 sicily 1390 Surprising Strings

<br />这道题其实也不是很难,只是有些小细节需要注意而已,刚开始想着用C++的string类型,后来想到都是取出字符中的两个字符而已,就想到了用数组了,嘿嘿...<br /> <br />// source code of submission 758043, Zhongshan University Online Judge System#include <iostream>#include <cstdio>#include <cstring>int main(){ in

2011-05-08 22:37:00 687

原创 sicily 1752 选择

<br />最近一直都在做水题找自信中,嘿嘿....<br /> <br />// source code of submission 743067, Zhongshan University Online Judge System#include <iostream>#include <cstring>#include <algorithm>using namespace std;int prime(int a[],int n) //筛法素数

2011-04-30 16:10:00 730

转载 POJ分类

<br />POJ上的一些水题(可用来练手和增加自信)<br />(poj3299,poj2159,poj2739,poj1083,poj2262,poj1503,poj3006,poj2255,poj3094)<br />初期:<br />一.基本算法:<br />     (1)枚举. (poj1753,poj2965)<br />     (2)贪心(poj1328,poj2109,poj2586)<br />     (3)递归和分治法.<br />     (4)递推.<br />     (5)

2011-04-29 13:07:00 456

原创 sicily 1685 Missile

<br />刚开始对题意理解错误,wa了几次....<br /> <br />// source code of submission 737521, Zhongshan University Online Judge System#include <iostream>using namespace std;int main(){ int n,i,j,mis[1006]; while(cin>>n,n) { int max = 1;

2011-04-25 16:25:00 666

原创 sicily 1624 Cryptoquote

<br />很简单的一道题,只是这里输入的字符串包含空格,因此要用到getline或则gets,而不能用scanf("%s",str)。。。。。<br /> <br />// source code of submission 737435, Zhongshan University Online Judge System#include <iostream>#include <cstdio>#include <cctype>#include <string>using namespac

2011-04-25 16:16:00 435

原创 sicily 1625 Binary Clock

<br />蛮简单的一道题,10进制转2进制,然后数组操作就OK了.....<br /> <br />// source code of submission 734146, Zhongshan University Online Judge System#include <iostream>#include <cstring>#include <cstdio>using namespace std;int main(){ int n,i,j,h,m,s; i

2011-04-22 12:12:00 488

原创 sicily 1491 Look and Say

<br />简单题.....<br /> <br /> <br />// source code of submission 733747, Zhongshan University Online Judge System#include <iostream>#include <string>using namespace std;int main(){ int n,i,num; string s; cin>>n; while(n--)

2011-04-22 11:01:00 467

原创 sicily 1394 Root of the Problem

<br />这道题理解了题意应该就很简单了吧..我用的是枚举,同时利用了指数函数的单调递增性,一旦试到某个A的N次方减去B大于当前的min值,就跳出循环,因为就算继续下去,只会得到更大的AN -B。<br /> <br /> <br />// source code of submission 733659, Zhongshan University Online Judge System#include <iostream>#include <cmath>using namespace std

2011-04-22 10:59:00 682

原创 sicily 1372 Bovine Latin

这道题还是比较简单的,就当做复习C++ 的string用法好了..// source code of submission 733589, Zhongshan University Online Judge System#include #include using namespace std;int main(){ string s; int n,i,len; cin>>n; while(n--) { cin

2011-04-22 10:50:00 518

原创 sicily 1137 河床

<br />// source code of submission 733540, Zhongshan University Online Judge System#include <iostream>#include <algorithm>using namespace std;int depth[30006],a[30000];int max_dis(int a [],int t) //求某个区间内最大数与最小数之差 {

2011-04-21 19:55:00 703

原创 sicily 1934移动小球

这道题在刘汝佳的《算法竞赛入门经典》里面有讲,之前用vector,超时!参考了别人的程序以后才AC,要注意输出语句的写法,以下是该题的算法(非原创)。// source code of submission 733152, Zhongshan University Online Judge System//这道题解强调小球之间的相对顺序,而非绝对顺序;//我们定义了结构体node,并用left,right来表示小球i的左边和右边小球的编号。//移动的过程分为两步:把小球X逸出序列;把X重新插入序

2011-04-21 15:36:00 1931 1

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除