代码:
#include
using namespace std;
int main()
{
int n;
while(scanf("%d",&n)==1)
{
int ans=0;
while(n!=1)
{
if(n%2==0)
n=n/2;
...
分类:
其他好文 时间:
2015-07-31 14:50:00
阅读次数:
96
摘要:中途相遇。对比map,快排+二分查找,Hash效率。n是4000的级别,直接O(n^4)肯定超,所以中途相遇法,O(n^2)的时间枚举其中两个的和,O(n^2)的时间枚举其他两个的和的相反数,然后O(logN)的时间查询是否存在。首先试了下map,果断TLE//TLE#include#incl...
分类:
其他好文 时间:
2015-07-31 14:42:30
阅读次数:
121
我们在工作中,有时候会需要将字符串转化为16进制字符串给用户,因为ASCII中有些字符,当我们使用printf("%s",p_ch);输出时会杂乱无章,如果采用16进制,会好很多。因此编写程序,代码如下:#include #include int strToHex(char *ch, char *h...
分类:
其他好文 时间:
2015-07-31 14:32:56
阅读次数:
130
第一步:找到httpd.conf 文件找到这一句:#Include conf/extra/httpd-vhosts.conf ,去掉前面的#,开启虚拟主机功能。第二步:在extra 下找到httpd-vhosts.conf 按照如下方式配置 DocumentRoot"c:...
分类:
其他好文 时间:
2015-07-31 14:31:14
阅读次数:
174
题目链接:hdu 5317 这题看数据量就知道需要先预处理,然后对每个询问都需要在 O(logn) 以下的复杂度求出,由数学规律可以推出 1 2 #include 3 #include 4 using namespace std; 5 const int N = 1000006; 6 7 ...
分类:
其他好文 时间:
2015-07-31 14:24:44
阅读次数:
129
求从0,0点到n-1,m-1点的最小二进制数
分两种情况:
1:若0,0点为‘1’,则为起点,进bfs贪心
2:若0,0点为‘0’,则找出起点所连接的所有‘0’点所能接触到的‘1’点,取其中离终点曼哈顿距离最小的点当做起点,保证01串最短
bfs贪心:每次只往右或下方走,对所有能到达的新点,若有0,则只进是0的点,否则进1
#include "stdio.h"
#incl...
分类:
其他好文 时间:
2015-07-31 13:12:30
阅读次数:
74
hdu 3549 网络流//邻接表
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include using n...
分类:
其他好文 时间:
2015-07-31 13:05:15
阅读次数:
94
通过引用可以大大减少创建临时变量的次数,从而提高程序运行的效率。
本文探讨创建通过引用减少创建临时变量的次数,与临时变量的生命周期。
测试一:不使用引用。#include
#include
using namespace std;
class Point{
private:
static int count;
int x;
public:
Point() {
x ...
分类:
其他好文 时间:
2015-07-31 13:02:35
阅读次数:
116
下例示范如何设定DLL,使之支持TLS.
#include
//This is the shared slot
static DWORD gdwTlsSlot;
BOOL DllMain(HINSTANCE hinst, DWORD fdwReason, LPVOID lpReserved)
{
LPVOID lpData;
UNREFERENCED_PARAMETER(hin...
分类:
编程语言 时间:
2015-07-31 13:02:34
阅读次数:
114
题意:有一些网络通过一些线路连接,求关键的连接,也就是桥,如果删除这个链接那么会产生两个子树分析:注意一下图不是连通图即可*******************************************************************#include#include#inclu...
分类:
其他好文 时间:
2015-07-31 12:54:11
阅读次数:
116