题目链接:11529 - Strange Tax Calculation
题意:平面上n个建筑物,3个建筑物可以组成一个三角形,计算平均每个三角形内有多少个点
思路:问题等价于,求凹四边形的占所有四边形的比例,用O(n^2)的算法,跟
HDU 3629 Convex
这题是一个道理
代码:
#include
#include
#include
#include
using...
分类:
其他好文 时间:
2014-05-23 08:00:18
阅读次数:
192
linux下实现多线程有两种函数调用:一种是通过pthread.h里面已经封装好的函数调用,另一种是通过unistd.h里面的fork函数调用。前面已经已经列举了pthread的使用,下面来书fork的例子。
一.fork函数
简单的fork例子
#include
#include
#include
using namespace std;
int main()
{...
分类:
编程语言 时间:
2014-05-23 07:59:41
阅读次数:
395
题目连接:uva 11174 - Stand in a Line
题目大意:村子里有n个村名民,现在他们要排成一列,处于对长辈的尊敬,他们不能排在自己父亲的前面,有些人的父亲不一定在村子了。问有多少种列的顺序。
解题思路:【算法竞赛入门经典-训练指南】的例题,主要还用到了欧几里得拓展定理求逆元。
#include
#include
#include
using namespa...
分类:
其他好文 时间:
2014-05-22 13:24:44
阅读次数:
179
以下四种情况,编译器将会合成(即由编译器负责)一个nontrivial默认构造函数。
1、成员对象带有默认构造函数
例如:
#include
using namespace std;
class Foo {
public:
Foo() { cout << "Foo" << endl; } // Foo类含有默认构造函数
};
class Bar {
pub...
分类:
其他好文 时间:
2014-05-22 13:24:06
阅读次数:
212
Interesting Calculator
CSU 过了 TOJ超时了 先记一下
#include
#include
#include
using namespace std;
int a[100];
bool b[100010];
int c[100010];
int d[100010];
int x, y;
int cas = 1;
struct node
{
int x, t,...
分类:
其他好文 时间:
2014-05-22 12:42:02
阅读次数:
249
#include
//#include
using namespace std;
struct node
{
char word[10];
int num;
};
node obj[100];
void my_word(char input[], char output[])
{
int sum=0,flag=0;...
分类:
其他好文 时间:
2014-05-22 12:41:25
阅读次数:
233
题目:
链接:点击打开链接
题意:
给出N种设备的价值和数量,怎样尽可能的平分。
算法:
多重背包。
思路:
1.转化为01背包解决。2.使用单调队列优化O(VN)算法。
代码:
法一:
#include
#include
#include
using namespace std;
int n;
int v[55],m[55];
int...
分类:
其他好文 时间:
2014-05-22 09:09:38
阅读次数:
205
#include//中缀表达式求值
#include
using namespace std;
int precede(char t1,char t2) //shuru//判断优先级
{
int t=0;
switch(t2)
{
case '+':
case '-':
if(t1=='(...
分类:
其他好文 时间:
2014-05-22 07:48:44
阅读次数:
237
#include
using namespace std;
int func(int year)//判断闰年的个数
{
int count=0;
for(int i=1990;i
if(year%4==0&&year%100!=0||year%400==0)
count++;
return cou...
分类:
其他好文 时间:
2014-05-22 06:34:15
阅读次数:
252
#include
#include
using namespace std;
struct node
{
int shi;
int xu;
int data;
};
int main()
{
int shinum=0;
int xunum=0;
int n;
cin>>n;
node*num=ne...
分类:
其他好文 时间:
2014-05-20 15:28:05
阅读次数:
256