【BZOJ4917】Hash Killer IV(简单数论)

对于左移加:其实就是解方程

由于i已确定 可以预处理出逆元

对于右移异或 可以直接模拟 因为前面一坨不会变

#include<bits/stdc++.h>
#define uint unsigned int
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	int T;
	cin>>T;
	while(T--)
	{
		uint x;
		cin>>x;
		x*=4294901761u;
		for(int i=31-11;i>=0;i--)
		{
			x^=((x>>(i+11))&1)<<i;
		}	
		x*=954437177u;
		for(int i=31-6;i>=0;i--)
		{
			x^=((x>>(i+6))&1)<<i;
		}
		x*=3222273025u;
		cout<<x<<'\n';
	} 
}
posted @ 2018-10-19 16:16  Patrickpwq  阅读(115)  评论(0编辑  收藏  举报