HDU 6129 暴力,規律

2022-08-31 04:03:07 字數 936 閱讀 1686

找規律

列出前幾項,斜著看,是楊輝三角 --> 組合數

異或滿足性質:

\(a \oplus b \oplus b = a\)

所以只需要關注組合數的奇偶性就可以了

規律是然後發現,對於\(a_2\)來說,就是\(a_1\)整體移了一位,所以如果判斷出\(c_^\),這是\(a_1\)在m次變換於\(a_i\)處異或次數,同樣上面的組合數也是\(a_2\)在m次變換在\(a_\)處的異或次數,所以可以將其都計算上去

判斷奇偶性可以數組合數分子分母2的個數

**

#include #include #include #include #include #include #include #include #include #include #include using namespace std;

typedef pairp;

typedef long long ll;

const int inf = 0x3f3f3f3f;

const double pi = acos(-1.0);

const double eps = 1e-9;

const int n = 2e5 + 5;

int t,a[n],ans[n];

ll getx(int n, int x)

return ans;

}int judge(int n, int m)

int n,m;

int main()

memset(ans, 0, sizeof(ans));

for(int i = 1; i <= n; i++)

}for(int i = 1; i <= n; i++)

printf("\n");

}return 0;

}

HDU 6129 規律 數論

給出一串長度為n的序列a,現在對a求m次字首異或和,求最後得到的陣列。題目不長,但其實隱藏了很多知識點。首先寫幾行找找規律 a b c d a ab abc abcd a aab aaabbc aaaabbbccd a aaab aaaaaabbbc aaaaaaaaaabbbbbbcccd 如果只...

HDU Just do it 找規律暴力

just do it 簡單打一下表,我們會發現,在第 m 次,第 x項對第 y 項的貢獻是 y x m 1m 1 由於是異或所以只與這個組合數是否為奇數有關,由lucus定理 這個數是奇數 y x m 1a ndm 1 1 為 了方便後面的計算,我們簡單的做乙個變換,考慮什麼時候 y x 對 y 有...

hdu2073 模擬規律

規律 按照題目意思來看我們可以把整個過程拆分成兩個操作不斷迴圈的步奏 每個迴圈包含兩種操作向上和向下 該次迴圈內範圍大概是乙個正方形的樣子 即x,y屬於0 a 1 向上的方向移動 由於上個迴圈中 我們在乙個正方形內 所以進入下乙個迴圈的時候我們的橫座標會 1 我們可以根據x的記錄來 1 則先y x ...