码迷,mamicode.com
首页 >  
搜索关键字:namespace    ( 41927个结果
C++排序(小堆排序)
#include #include using namespace std; template class MinHeap { public: MinHeap(int sz=DefaultSize) { capacity = sz>DefaultSize?sz:DefaultSize; heap = new Type[capacity]; size = 0; } MinHea...
分类:编程语言   时间:2015-04-08 18:05:40    阅读次数:149
hdu 1856 More is better
简单并查集,985ms险过,注意n=0时输出1 #include #include #define maxn 10000000+5 using namespace std; int a[maxn],b[maxn]; int dfs(int x) { if(a[x]!=x) { a[x]=dfs(a[x]); } return a[x]; } int main() { int n; ...
分类:其他好文   时间:2015-04-08 16:34:19    阅读次数:116
经典排序
#include#include#include#include#includeusing namespace std;//求最大公约数int gcd(int a, int b){ if (b == 0) return a; return gcd(b,a%b);}//---...
分类:编程语言   时间:2015-04-08 16:19:54    阅读次数:148
UVa 11078 - Open Credit System
題目:給你一些學生的分數,任何前面的學生等級都高於他後面的學生,             問等級高的學生比等級低的學生的分數差最大值。 分析:簡單題。保存當前最大值,做差求解即可。 說明:╮(╯▽╰)╭。 #include #include #include #include #include #include using namespace std; int score[...
分类:其他好文   时间:2015-04-08 15:08:16    阅读次数:78
hdu 2103
心情不好,刷道水题. #include #include using namespace std; int main() { int t; cin>>t; while(t--) { int m,n; cin>>m>>n; int flag=-1; int sum=0,t=0; if(m==0) flag++; for(int i=1;i<=n;i++) { ...
分类:其他好文   时间:2015-04-08 15:07:30    阅读次数:122
大整数运算---模拟笔算
/* *m=a[k]×10k-1+a[k-1]×10k-2+….+a[2]×10+a[1] *其中a[0]保存该长整数的位数。 * *模拟笔算 */ #include #include using namespace std; #define SIZE 255 void getl(char* n);//获取长整数 void prt(char* n);//打印长整数 int cmp(char* n...
分类:其他好文   时间:2015-04-08 15:04:43    阅读次数:139
poj 3425 Customer support 模拟
模拟水题。 代码: //poj 3425 //sep9 #include using namespace std; const int maxN=1000024; int vis[maxN]; int main() { int n; memset(vis,0,sizeof(vis)); int q,a,x,sum=0,correct_num=0; scanf("%d",&n); ...
分类:其他好文   时间:2015-04-08 13:17:19    阅读次数:145
poj 3587 The Biggest Cake 正弦定理
题意: 给n个点,求其中3个点构成三角形的最大外接圆半径。 分析: 正弦定理,A/sina=B/sinb=C/sinc=ABC/(2*s)=2*R。 代码: //poj 3587 //sep9 #include #include using namespace std; const int maxN=700; double dis[maxN][maxN]; double x[maxN...
分类:其他好文   时间:2015-04-08 13:13:21    阅读次数:141
最长上升子序列nlogn解法详解 poj 2533
先上一个n^2的算法: 1 #include 2 using namespace std; 3 4 const int N = 1000; 5 int a[N]; 6 int g[N]; 7 8 int main () 9 {10 int n;11 while ( cin >>...
分类:其他好文   时间:2015-04-08 13:03:13    阅读次数:117
八皇后 2333
#includeusing namespace std;int map[8][8]={0};int ct=0;int safe_ab(int a,int b){ for(int i=0;i<8;i++)//行判断 { if(map[a][i]==3) { return 0; } } f...
分类:其他好文   时间:2015-04-08 13:03:08    阅读次数:107
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!