题目//找规律,123321123321123321…发现这样排列恰好可以错开// 其中注意题中数据范围: M是行,N是列,3 #include#include#includeusing namespace std;int main(){ int n, m; while( scanf( ...
分类:
其他好文 时间:
2014-07-16 22:55:54
阅读次数:
143
有关const成员、static成员、const static成员的初始化:
1、const成员:只能在构造函数后的初始化列表中初始化
2、static成员:初始化在类外,且不加static修饰
3、const static成员:类只有唯一一份拷贝,且数值不能改变。因此,可以在类中声明处初始化,也可以像static在类外初始化
#include
using std::cout;
...
分类:
编程语言 时间:
2014-07-11 08:16:29
阅读次数:
299
UVA 10548 - Find the Right Changes
题目链接
题意:给定a,b,c,表示货物的价值,求由A货物和B货物组成C货物有几种方法,判断有无解和是否有无限多种
思路:扩展欧几里得求通解,去计算上限和下限就能判断
代码:
#include
#include
#include
#include
using namespace std;
...
分类:
其他好文 时间:
2014-07-11 00:22:22
阅读次数:
419
#include
#include
#include
#include
#include
using namespace std;
#define point Point
const double eps = 1e-8;
const double PI = acos(-1.0);
double ABS(double x){return x>0?x:-x;}
int sgn(double x){...
分类:
其他好文 时间:
2014-07-10 23:54:16
阅读次数:
253
题意:求最大的三角形
思路:先初始化从左到右和从右到左的最大连续的‘-’,然后就是当奇数列的时候找头向下的三角形,偶数的时候相反找
#include
#include
#include
#include
using namespace std;
const int MAXN = 200;
char map[MAXN][MAXN];
int Left[MAXN][MAXN], Rig...
分类:
其他好文 时间:
2014-07-10 22:09:52
阅读次数:
272
新单词unidirectional get T T
求有向图上,以某点为根的,最小生成树
参考别人的模板
#include
#include
#include
#include
#include
#include
#include
#define inf 2000000000
using namespace std;
struct node1
{
double x,...
分类:
Web程序 时间:
2014-07-10 20:32:47
阅读次数:
285
知道降幂公式这题就很好办了 B>=Phi(c)的时候可以降幂然后快速幂计算,否则就直接快速幂计算。
这里的大数对小数取模直接利用取模性质按位取就行了。
//A^B %C=A^( B%phi(C)+phi(C) ) %C
#include
#include
#include
#include
#include
#include
using namespace std;
typedef _...
分类:
其他好文 时间:
2014-07-10 19:58:21
阅读次数:
217
经验:当std::swap对你的类型效率不高时,提供一个swap成员函数,并确定这个函数不抛出异常
示例:
stl里的swap算法
namespace std{
template
void swap(T &a, T &b){
T temp(a);
a = b;
b = temp;
}
}
//“pimpl手法”(pointer to implementation) --> 文件间的编译依存度
class WidgetImpl{
public:
//...
pr...
分类:
编程语言 时间:
2014-07-10 19:35:50
阅读次数:
240
经验:尽可能延后变量定义式的出现。这样做可增加程序的清晰度并改善程序效率。
示例:
//这个函数过早定义变量“encrypted”
std::string encryptPassword(const std::string &password){
using namespace std;
string encrypted;
if(password.length() < MinimumPasswordLength){
throw logic_error("Password is too short"...
分类:
编程语言 时间:
2014-07-10 19:27:30
阅读次数:
253
点击打开链接
简单
模拟机器人的移动,发生碰撞时输出相应的信息。
code
#include
#include
using namespace std;
struct node{
int k;
int s;
}
mtx[200][200];
struct node1{
int x, y;
}
rob[200];
int n, m;
int...
分类:
其他好文 时间:
2014-07-10 17:25:11
阅读次数:
153