• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ vll类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中vll的典型用法代码示例。如果您正苦于以下问题:C++ vll类的具体用法?C++ vll怎么用?C++ vll使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了vll类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: merge

void merge(vll &L, vll &R, vll &A){
	ll i=0,j=0,k=0,iL,jL;
	iL = L.size();
	jL = R.size();
	while(i<iL && j<jL ){
		if(L[i]<=R[j]){
			A[k] = L[i];
			i++;
		}
		else if(R[j]<=L[i]){
			A[k] = R[j];
			j++;
		}
		k++;
	}
	while(i<iL){
			A[k] = L[i];
			i++;
			k++;
	}
	
	while(j<jL){
			A[k] = R[j];
			j++;
			k++;
	}
	
	return;
}
开发者ID:tushar-rishav,项目名称:Algorithms,代码行数:29,代码来源:merge_sort.cpp


示例2: matmul

vll matmul(const vll &A, const vll &B) {
    int m = A.size();
    int n = B[0].size();
    int x = B.size();
    vll C(m, vector<long long>(n, 0));
    
    for (int i=0; i<m; ++i) {
        for (int j=0; j<n; ++j) {
            for (int k=0; k<x; ++k) {
                C[i][j] = (C[i][j] + A[i][k]*B[k][j]) % mod;
            }
        }
    }
    
    return C;
}
开发者ID:alxsoares,项目名称:contest-problem-solutions,代码行数:16,代码来源:TheLongPalindrome.cpp


示例3: main

int main(){
	ll n,m,u,v,c;
	while(cin >> n >> m && (n||m)){
		
		s=1,t=n+1; N=n+2; pi.assign(N,INF);
		cap.assign(N,vll(N,0)); flow.assign(N,vll(N,0)); cost.assign(N,vll(N,0));

		vector<ll> U,V,C; 
		for(int i=0 ; i<m ; i++){
			cin >> u >> v >> c;
			U.push_back(u); V.push_back(v); C.push_back(c);

		}
		ll D, K; cin >> D >> K;
		for(int i=0 ; i<m ; i++){
			u=U[i] , v=V[i], c= C[i];
			cost[u][v]=c; cost[v][u]=c;
			 cap[u][v]=K;  cap[v][u]=K;
		}
		cap[n][t]=D; cost[n+1][t]=0;
		mincost=0; maxflow=0; MCMF();
		if(maxflow==D) cout << mincost << endl;
		else cout << "Impossible." << endl;
	}
	return 0;
}
开发者ID:ImnIrdst,项目名称:ICPC-Practice-2015-TiZii,代码行数:26,代码来源:UVa+10594+-+Data+Flow+-+AC.cpp


示例4: main

int main(){
	ios_base::sync_with_stdio(false);
	int T;
	ll a, b;
	cin >> T;
	preprocess();
	 while(T--){
		cin >> a >> b;
		if(a == b){
			cout << test(a) << '\n';
			continue;
		}
		vll::iterator first = lower_bound(nums.begin(), nums.end(),a), last = lower_bound(nums.begin(), nums.end(),b);
		cout << (int)(last - first) + (*last == b) << '\n';
		
	}
}
开发者ID:caioaao,项目名称:cp-solutions,代码行数:17,代码来源:SDSQUARE.cpp


示例5: mul

vll mul(const vll & va, const vll & vb) {
  int len = 32 - __builtin_clz(std::max(va.size(), vb.size()) - 1);
  len = 1 << (len + 1);
  vcd a(len), b(len);
  for (int i = 0; i < (int)va.size(); i++) a[i] = cd(va[i], 0);
  for (int i = 0; i < (int)vb.size(); i++) b[i] = cd(vb[i], 0);
  a = fft(a);
  b = fft(b);
  for (int i = 0; i < len; i++) {
    double real = a[i].real() * b[i].real() - a[i].imag() * b[i].imag();
    a[i].imag() = a[i].imag() * b[i].real() + b[i].imag() * a[i].real();
    a[i].real() = real;
  }
  a = fft(a, true);
  vll res(len);
  for (int i = 0; i < len; i++) res[i] = (long long)(a[i].real() + 0.5);
  return res;
}
开发者ID:irajdeep,项目名称:Algorithm-Anthology,代码行数:18,代码来源:4.4.3+FFT+and+Multiplication.cpp


示例6: solve

ll solve(vll dat)
{
    
    int sz=dat.size();
    for(int i=1;i<sz;i++)
    {
        if(i==1)
            dat[i]=max(dat[i-1], dat[i]);
        else
            dat[i]=max(dat[i-1], dat[i]+dat[i-2]);
    }
    return dat[sz-1];
}
开发者ID:krishnaanaril,项目名称:SPOJ,代码行数:13,代码来源:SAMER08C.cpp


示例7: all

void all( vll& v, vll& l )
{
	for( int i = 0; i < v.size(); ++i )
	{
		vll tmp, comb;
		for( vlli j = l.begin(); j != l.end(); ++j )
			tmp.push_back( *j + v[ i ] );
		for( vlli m = l.begin(), n = tmp.begin(); m != l.end() || n != tmp.end(); )
			comb.push_back( n == tmp.end() || m != l.end() && *m <= *n? *m++ : *n++ );
		l.swap( comb );
	}
}
开发者ID:dibery,项目名称:UVa,代码行数:12,代码来源:12911.cpp


示例8: matexp

vll matexp(vll A, int n) {
    int m = A.size();
    vll ret = matunit(m);

    while (n > 0) {
        if (n & 1) {
            ret = matmul(ret, A);
        }
        A = matmul(A, A);
        n >>= 1;
    }

    return ret;
}
开发者ID:alxsoares,项目名称:contest-problem-solutions,代码行数:14,代码来源:TheLongPalindrome.cpp


示例9: matadd

vll matadd(const vll &A, const vll &B) {
    int m = A.size();
    int n = A[0].size();
    vll C(m, vector<long long>(n, 0));
    for (int i=0; i<m; ++i) {
        for (int j=0; j<n; ++j) {
            C[i][j] = A[i][j] + B[i][j];
            if (C[i][j] >= mod) {
                C[i][j] -= mod;
            }
        }
    }
    
    return C;
}
开发者ID:alxsoares,项目名称:contest-problem-solutions,代码行数:15,代码来源:TheLongPalindrome.cpp


示例10: merge_sort

vll merge_sort(vll S){
	vll tempL,tempR;
	ll len = S.size();
	if(len < 2 )
		return S;	// array is already sorted. Base case
	rep(i,len/2)
		tempL.pub(S[i]);
	repk(i,len/2,len)
		tempR.pub(S[i]);
	tempL = merge_sort(tempL);
	tempR = merge_sort(tempR);
	merge(tempL,tempR,S);
	return S;

}
开发者ID:tushar-rishav,项目名称:Algorithms,代码行数:15,代码来源:merge_sort.cpp


示例11: karatsubaMultiply

    static vll karatsubaMultiply(const vll &a, const vll &b) {
        int n = a.size();
        vll res(n + n);
        if (n <= 32) {
            for (int i = 0; i < n; i++)
                for (int j = 0; j < n; j++)
                    res[i + j] += a[i] * b[j];
            return std::move(res);
        }

        int k = n >> 1;
        vll a1(a.begin(), a.begin() + k);
        vll a2(a.begin() + k, a.end());
        vll b1(b.begin(), b.begin() + k);
        vll b2(b.begin() + k, b.end());

        vll a1b1 = karatsubaMultiply(a1, b1);
        vll a2b2 = karatsubaMultiply(a2, b2);

        for (int i = 0; i < k; i++)
            a2[i] += a1[i];
        for (int i = 0; i < k; i++)
            b2[i] += b1[i];

        vll r = karatsubaMultiply(a2, b2);
        for (int i = 0; i < (int)a1b1.size(); i++)
            r[i] -= a1b1[i];
        for (int i = 0; i < (int)a2b2.size(); i++)
            r[i] -= a2b2[i];

        for (int i = 0; i < (int)r.size(); i++)
            res[i + k] += r[i];
        for (int i = 0; i < (int)a1b1.size(); i++)
            res[i] += a1b1[i];
        for (int i = 0; i < (int)a2b2.size(); i++)
            res[i + n] += a2b2[i];
        return std::move(res);
    }
开发者ID:condy0919,项目名称:uva-code,代码行数:38,代码来源:254.cpp


示例12: in_lookup

bool in_lookup(const vll &l, long long n) // Lookup table method
{
    return std::find(l.begin(), l.end(), n) != l.end();
}
开发者ID:wxv,项目名称:Algorithms,代码行数:4,代码来源:euler_sum_of_powers.cpp


示例13: preprocess

void preprocess(){
	nums.push_back(0);
	ll sqr = 1, i = 1;
	while(sqr <= max_n){
		if(test(sqr) && sqr%i == 0) nums.push_back(sqr);
		i++; sqr = i*i;
	}
}
开发者ID:caioaao,项目名称:cp-solutions,代码行数:8,代码来源:SDSQUARE.cpp


示例14: cal

ll cal() {
    vec.push_back(0);
    vec.push_back(1);
    ll add = 2;
    ll a = 2;
    for (int i = 2; i < 1000001; ++i) {
        vec.push_back(vec[i - 1] + a);
        i++;
        a += add;
        vec.push_back(vec[i - 1] + a);
        a += add;
        add++;
    }
}
开发者ID:ZahraParsaeian,项目名称:Uva_Solved_Problems,代码行数:14,代码来源:11401+Triangle+Counting.cpp


示例15: gen

void gen(void)
{
    LL i,j,k;
    for(i=1;i<=1005;i++) arr[i]=i*i*i;
    for(i=1; i<=1005; i++)
    {
        for(j=i+1; j<=1005; j++)
        {
            k=arr[i]+arr[j];
            mp[k]++;
            if(mp[k]==2) cont.pb(k);
        }
    }
    sort(cont.begin(),cont.end());
    return;
}
开发者ID:rofi93,项目名称:UVA,代码行数:16,代码来源:962.cpp


示例16: init

void init()
{
    int i=0 , j;

    LL pnum=0 , p=1;

    sll st;
    sll::iterator it;

    for(i=0; i<plen; i++)
    {
        pnum = prm[i];

        for(j=2; j<=40; j++)
        {
           //pnum = power(prm[i] , j);

           p=1;

           for(int k=1; k<=j; k++)
           {
               p*=pnum;

               if(p > mxhigh) break;
           }

           if(p < mxhigh)
           {
               st.insert(p);
           }
        }
    }

    //cerr << st.size();

    for(it=st.begin() ; it!=st.end() ; ++it)
    {
        v.push_back(*it);
    }

    //for(i=0; i<100; i++) cout << v[i] << " ";
    //cout << v.size();
    //cout << v[v.size()-1];
    vlen = v.size();
}
开发者ID:shidhu,项目名称:Competetive-Programming,代码行数:45,代码来源:Dev+Skill+_Mr.+And+Mrs.+A.cpp


示例17: dijkstra

ll dijkstra(int s, int t){
	found.assign(N,0); dist.assign(N,INF); f.assign(N,0); dad.assign(N,pii(-1,2));
	dist[s]=0; f[s]=INF;
	while(s!=-1){
		int best=-1; found[s]=true;
		for(int k=0 ; k<N; k++){
			if(found[k]) continue;
			relax(s,k,cap[s][k]-flow[s][k],cost[s][k],1);
			relax(s,k,flow[k][s],-1*cost[k][s],-1);
			if(best==-1 || dist[k]<dist[best]) best=k;
		}
		s=best;
	}
	for(int k=0 ; k<N ; k++){
		pi[k]=min(pi[k]+dist[k],INF);
	}
	return f[t];
}
开发者ID:ImnIrdst,项目名称:ICPC-Practice-2015-TiZii,代码行数:18,代码来源:UVa+10594+-+Data+Flow+-+AC.cpp


示例18: prec

void prec()
{
    ll i,j,k,l;
    for(i=1; i<INT_MAX; i*=2)
        for( j=i; j<INT_MAX; j*=3)
            for( k=j; k<INT_MAX; k*=5)
                for( l=k; l<INT_MAX; l*=7)
                    num.pb(l);
    sort(all(num));
}
开发者ID:darkprinx,项目名称:ACM-SOLUTION,代码行数:10,代码来源:443-+Humble+Number.cpp


示例19: main

int main ()
{
	ll mid;

	ll i,j,k,x,ans=0,depend,l,n,ind;
	
	cin>>n>>m>>depend;
	fr(i,n)
	{
		cin>>x;
		man.push_back(x);
	}
开发者ID:crystal95,项目名称:Competetive-Programming-at-different-platforms,代码行数:12,代码来源:renting.cpp


示例20: count

	int count(int n, int k) {
        K = k;
        T.assign(27, vector<long long>(27, 0));
        int start_row = 0;
        for (int j=1; j<27; ++j) {
            T[start_row][j] = 27-j;
            T[++start_row][j] = j;
        }
        if (n & 1) {
            return ((n>1 ? S((n-1)/2) : 0) + S((n+1)/2)) % mod;
        } else {
            return 2*S(n/2) % mod;
        }
	}
开发者ID:alxsoares,项目名称:contest-problem-solutions,代码行数:14,代码来源:TheLongPalindrome.cpp



注:本文中的vll类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ vmap类代码示例发布时间:2022-05-31
下一篇:
C++ visitor类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap