#include
#include
#include
using namespace std;
typedef long long LL;
const int maxn = 10000010;
int mu[maxn], prime[maxn], vis[maxn], sum[maxn];
int cnt;
int a, b;
void mobi(int n)
{
mu[1] = 1;...
分类:
其他好文 时间:
2015-03-11 17:29:53
阅读次数:
113
方法一:计算掩码位数有两种方法,使用LOG或位运算都可以;使用LOG要注意向上取整和+3,而不是+2,+2计算不对,通不过。换底公式log a(b)=log c(b)/log c(a);C语言只有log以e为底,log10以10为底。
#include
#include
using namespace std;
int GetNum(int x)
{
double y;
y=log10...
分类:
其他好文 时间:
2015-03-11 17:29:36
阅读次数:
137
借助C语言中的库函数strstr,可以避免写KMP;循环判断即可。
#include
using namespace std;
int main()
{
char a[200001],b[100001];
int i,len;
bool f;
while(gets(a))
{
f=0;
gets(b);
if(strlen(b)>strlen(a)) cout<...
分类:
其他好文 时间:
2015-03-11 17:24:17
阅读次数:
117
//
// main.cpp
// uva331
//
// Created by Fangpin on 15/3/11.
// Copyright (c) 2015年 FangPin. All rights reserved.
//
#include
#include
#include
using namespace std;
vector a,b;
int ans,n;
bo...
分类:
其他好文 时间:
2015-03-11 17:16:09
阅读次数:
109
注意只有一个负数时,负数也算最大值。
#include
using namespace std;
int main()
{
int a[100001];
int T,T2=0,n,i;
int sum,maxsum,start,maxstart,maxend;
cin>>T;
while(T--)
{
cin>>n;
for(i=0;i>a...
分类:
其他好文 时间:
2015-03-11 17:10:39
阅读次数:
104
#include#includeusing namespace std;typedef long long ll; //【skill】重命名struct num{ ll zi,mu; //分子分母};ll gcd(ll a,ll b) //求最大公约数{ return ...
分类:
其他好文 时间:
2015-03-11 16:33:00
阅读次数:
145
一定要注意IP的长度不能超过15位。
方法一:
#include
using namespace std;
bool f(char* p)
{
int state,sum;
state=sum=0;
while(true)
{
switch(state)
{
case 0:
case...
分类:
其他好文 时间:
2015-03-11 14:50:29
阅读次数:
115
http://www.lydsy.com/JudgeOnline/problem.php?id=1086题意:n个点的树,要求分块,使得每一块的大小在[b, 3b]内且块与某个点形成的块是连通的(某个点既可以是块内也可以在块外)(nusing namespace std;const int N=10...
分类:
其他好文 时间:
2015-03-11 14:39:16
阅读次数:
109
#include using namespace std; class CMyInt{private: int value;public: CMyInt(int x):value(x){} CMyInt():value(0){} //++i CMyInt & ope...
分类:
其他好文 时间:
2015-03-11 14:21:22
阅读次数:
112
代码如下:#include using namespace std;templateclass Base {public: void SayHi() { T* pT = static_cast(this); pT->PrintClassName(); }...
分类:
其他好文 时间:
2015-03-11 12:38:20
阅读次数:
159