zoukankan      html  css  js  c++  java
  • 等差数列连续异或模板

    网上找的模板,还不太懂,改了下,先留着

    #include <cstdio>
    #include <ctime>
    #include <cstdlib>
    #include <cstring>
    #include <queue>
    #include <string>
    #include <set>
    #include <stack>
    #include <map>
    #include <cmath>
    #include <vector>
    #include <iostream>
    #include <algorithm>
    #include <bitset>
    #include <fstream>
    using namespace std;
    
    
    //LOOP
    #define FF(i, a, b) for(int i = (a); i < (b); ++i)
    #define FE(i, a, b) for(int i = (a); i <= (b); ++i)
    #define FED(i, b, a) for(int i = (b); i>= (a); --i)
    #define REP(i, N) for(int i = 0; i < (N); ++i)
    #define CLR(A,value) memset(A,value,sizeof(A))
    #define FC(it, c) for(__typeof((c).begin()) it = (c).begin(); it != (c).end(); it++)
    
    
    //OTHER
    #define SZ(V) (int)V.size()
    #define PB push_back
    #define MP make_pair
    #define all(x) (x).begin(),(x).end()
    
    
    //INPUT
    #define RI(n) scanf("%d", &n)
    #define RII(n, m) scanf("%d%d", &n, &m)
    #define RIII(n, m, k) scanf("%d%d%d", &n, &m, &k)
    #define RIV(n, m, k, p) scanf("%d%d%d%d", &n, &m, &k, &p)
    #define RV(n, m, k, p, q) scanf("%d%d%d%d%d", &n, &m, &k, &p, &q)
    #define RS(s) scanf("%s", s)
    
    
    //OUTPUT
    #define WI(n) printf("%d
    ", n)
    #define WS(n) printf("%s
    ", n)
    
    
    //debug
    //#define online_judge
    #ifndef online_judge
    #define debugt(a) cout << (#a) << "=" << a << " ";
    #define debugI(a) debugt(a) cout << endl
    #define debugII(a, b) debugt(a) debugt(b) cout << endl
    #define debugIII(a, b, c) debugt(a) debugt(b) debugt(c) cout << endl
    #define debugIV(a, b, c, d) debugt(a) debugt(b) debugt(c) debugt(d) cout << endl
    #else
    #define debugI(v)
    #define debugII(a, b)
    #define debugIII(a, b, c)
    #define debugIV(a, b, c, d)
    #endif
    
    typedef long long LL;
    typedef unsigned long long ULL;
    typedef vector <int> VI;
    const int INF = 0x3f3f3f3f;
    const double eps = 1e-10;
    const int MOD = 100000007;
    const int MAXN = 1000010;
    const double PI = acos(-1.0);
    
    LL Get(LL dis, LL l, LL P, LL number)
    {
    	LL ret = 0;
    	ret += (l / P) * number;
    	l %= P;
    	ret += (dis / P) * number * (number - 1) / 2;
    	dis %= P;
    	if (dis * number + l < P)
            return ret;
    	else
            return ret + Get(P, (dis * number + l) % P, dis, (dis * number + l) / P);
    }
    
    LL GetYiHuo(LL l, LL r, LL dis)  //以x开始, y为结束, dis为等差 连续异或
    {
        //number为计算的个数
        LL number = (r - l) / dis + 1, ans = 0, Sum, P = 1;
        for (LL i = 1; i <= 10; i++)
        {
            Sum = Get(dis, l, P, number);
            if (Sum & 1)
                ans += P;
            P <<= 1;
        }
        return ans;
    }
    
    int main()
    {
        //freopen("input.txt", "r", stdin);
        return 0;
    }
    


  • 相关阅读:
    android AudioManager AUDIOFOCUS
    uboot环境变量实现分析
    观察者模式总结
    【BZOJ3270】博物馆 概率DP 高斯消元
    从零開始学android&lt;TabHost标签组件.二十九.&gt;
    怎样在Web项目中的service业务层获取项目根路劲
    TexturePacker 算法
    [leetCode 75] Sort Colors
    无人车可能导致器官捐献者短缺以及吸烟率下降:4星|《无人驾驶,十万亿美元的大饼怎么分?》
    如何寻找颠覆式创新的机会,《创新者的窘境》作者二十年磨一剑:4星|《与运气竞争》
  • 原文地址:https://www.cnblogs.com/suncoolcat/p/3395472.html
Copyright © 2011-2022 走看看