[考试总结]noip模拟32

爆炸!!!!!

好废啊!!!!

挂分王!!!!

然而这一次还有热心家长传播排名

只能怪你废。。。

\(T1\)\(while\)写成了 \(if\) 挂没 \(20pts\)

然后 \(T3\)\(long\;long\) 卡精度然而没有开 \(long\;long\)?!

都是些什么 \(2B\) 错误!!!

然后还有完全平方数。

为什么在分解约数的时候不考虑这个???

活该 \(\color{white}{XIN大sb}\)

Smooth

用队列就可以解决,就是开 \(b\) 个队列,之后就可以每次取出最小的队首,之后每个做乘法,之后再加入进入队中。。



#include<bits/stdc++.h>
using std::cout; using std::endl;
#define try(i,a,b) for(register signed i=a;i<=b;++i)
#define throw(i,a,b) for(register signed i=a;i>=b;--i)
#define asm(i,x) for(register signed i=head[x];i;i=edge[i].next)
namespace xin_io
{
	#define debug cout<<"debug"<<endl
	#define enum(x) cout<<#x" = "<<x<<endl;
	#define gc() p1 == p2 and (p2 = (p1 = buf) + fread(buf,1,1<<20,stdin),p1 == p2) ? EOF : *p1++
	char buf[1<<20],*p1 = buf,*p2 = buf; int ak; typedef long long ll; typedef unsigned long long ull;
	class xin_stream{public:template<typename type>inline xin_stream &operator >> (type &x)
	{
		register type s = 0; register int f = 1; register char ch = gc();
		while(!isdigit(ch)) {if(ch == '-') f = -1; ch = gc();}
		while( isdigit(ch)) s = (s << 1) + (s << 3) + (ch  xor 48),ch = gc(); return x = s * f,*this;
	}}io;
}
#define int long long
using namespace xin_io; static const int maxn = 1e6+10,inf = 1e9+7,mod = 998244353; const ll llinf = 1e18+7;
namespace xin
{
	const int prime[] = {0,2,3,5,7,11,13,17,19,23,29,31,37,41,43,47};
	std::queue<int>q[17];
	int k,b;
	int cnt = 0;
	inline short main()
	{
		io >> b >> k; cnt = 1;
		try(i,1,b) q[i].push(prime[i]);
		while(1)
		{
			int minn = llinf,minp;
			try(i,1,b) if(q[i].front() < minn) minn = q[i].front(),minp = i;
			q[minp].pop(); cnt ++ ;
			try(i,minp,b)
				q[i].push(prime[i] * minn);
			if(cnt >= k) {cout<<minn<<endl; exit(0);}
		}
		return 0;
	}
}
signed main() {return xin::main();}

Six

这题目爆搜似乎给的很厚。

然后就是我们考虑状压。。

发现质因子最多只有 \(6\)

然后我们发现:

\(^{2^6}=2^64\)

那么可以开始 二倍状压

之后进行记忆化搜索



#include<bits/stdc++.h>
using std::cout; using std::endl;
#define try(i,a,b) for(register signed i=a;i<=b;++i)
#define throw(i,a,b) for(register signed i=a;i>=b;--i)
#define asm(i,x) for(register signed i=head[x];i;i=edge[i].next)
namespace xin_io
{
	#define debug cout<<"debug"<<endl
	#define enum(x) cout<<#x" = "<<x<<endl;
	#define gc() p1 == p2 and (p2 = (p1 = buf) + fread(buf,1,1<<20,stdin),p1 == p2) ? EOF : *p1++
	char buf[1<<20],*p1 = buf,*p2 = buf; int ak; typedef long long ll; typedef unsigned long long ull;
	class xin_stream{public:template<typename type>inline xin_stream &operator >> (type &x)
	{
		register type s = 0; register int f = 1; register char ch = gc();
		while(!isdigit(ch)) {if(ch == '-') f = -1; ch = gc();}
		while( isdigit(ch)) s = (s << 1) + (s << 3) + (ch  xor 48),ch = gc(); return x = s * f,*this;
	}}io;
}
#define int long long
using namespace xin_io; static const int maxn = 1e6+10,inf = 1e9+7,mod = 1e9+7;ll llinf = 1e18+7;
namespace xin
{
	#define lowbit(i) (i & -i)
	#define mp xin_data
	std::pair<int,int>pri[maxn]; int cnt = 0;
	int n,d[maxn];
	int ji[maxn];
	class xin_data
	{
		private:
			friend bool operator < (xin_data x,xin_data y)
			{return x.x == y.x ? x.y < y.y : x.x < y.x;}
		public:
			int x,y;
			xin_data(){}
			xin_data(int x,int y):x(x),y(y){}
	};
	std::map<xin_data,int>f;
	int dfs(int st1,int st2)
	{
		if(f[mp(st1,st2)]) return f[mp(st1,st2)];
		f[mp(st1,st2)] = 1;
		try(i,1,(1 << cnt) - 1)
		{
			register int temp = 0,ok = 0,vis = 0;
			try(j,1,(1 << cnt) - 1)
			{
				if((i & j) == false) continue; //没有交集的时侯.
				if((st1 >> j) & 1) temp ++; if((st2 >> j) & 1) ok = 1;
				if(ok or temp > 1) {vis = 1;break;}
			}
			if(vis) continue;
			if((st1 >> i) & 1) (f[mp(st1,st2)] += d[i] * dfs(st1 xor (1ll << i) ,st2 | (1ll << i)) % mod) %= mod;
			else (f[mp(st1,st2)] += d[i] * dfs(st1 | (1ll << i) ,st2) % mod) %= mod;
		}
		return f[mp(st1,st2)] % mod;
	}
	inline short main()
	{
		io >> n;
		for(register int i=2;i *i <= n;++i)
		if(n % i == 0)
		{
			pri[++cnt].first = i;
			while(n % i == 0)
			{
				pri[cnt].second++;
				n /= i;
			}
		}
		if(n xor 1) pri[++cnt] = std::make_pair(n,1);
		d[0] = 1;
		try(i,1,cnt) ji[1 << (i - 1)] = i;
		try(i,1,(1 << cnt) - 1) d[i] = d[i xor lowbit(i)] * pri[ji[lowbit(i)]].second;
		printf("%lld\n",dfs(0,0)-1);
		return 0;
	}
}
signed main() {return xin::main();}

Walker

我们其实只需要两个方程就可以开始高斯消元

然而有错误的

我们这就可以开始随机化

我们其实只用随机几十组。

这样几乎不会出现错误。

然后就是普通的高斯消元



#include<bits/stdc++.h>
using std::cout; using std::endl;
#define try(i,a,b) for(register signed i=a;i<=b;++i)
#define throw(i,a,b) for(register signed i=a;i>=b;--i)
#define asm(i,x) for(register signed i=head[x];i;i=edge[i].next)
namespace xin_io
{
	#define debug cout<<"debug"<<endl
	#define enum(x) cout<<#x" = "<<x<<endl;
	#define gc() p1 == p2 and (p2 = (p1 = buf) + fread(buf,1,1<<20,stdin),p1 == p2) ? EOF : *p1++
	char buf[1<<20],*p1 = buf,*p2 = buf; int ak; typedef long long ll; typedef unsigned long long ull;
	class xin_stream{public:template<typename type>inline xin_stream &operator >> (type &x)
	{
		register type s = 0; register int f = 1; register char ch = gc();
		while(!isdigit(ch)) {if(ch == '-') f = -1; ch = gc();}
		while( isdigit(ch)) s = (s << 1) + (s << 3) + (ch  xor 48),ch = gc(); return x = s * f,*this;
	}}io;
}
#define int long long
using namespace xin_io; static const int maxn = 1e6+10,inf = 1e9+7,mod = 998244353; const ll llinf = 1e18+7;
namespace xin
{
	class xin_data
	{
		public:
			double x,y,lx,ly;
	}d[maxn];
	const double eps = 1e-6,pi = 3.14159265358979;
	double a[10][10],ans[100];
	inline void gss(int n)
	{
		for(register int i=1;i<=n;++i)
		{
			int k = i;
			double t;
			for(register int j=i+1;j<=n;++j)
				if(fabs(a[k][i]) < fabs(a[j][i]))
					k = j;				
			if(k != i) 
				for(register int j=1;j<=n+1;++j)
					t = a[k][j],a[k][j] = a[i][j],a[i][j] = t; 
//			if(fabs(a[i][i]) >= eps)
				for(register int j=1;j<=n;++j)
				{
					if(i != j)
					{
						t = a[j][i] / a[i][i];
						for(register int k=1;k<=n+1;++k)
							a[j][k] -= t * a[i][k];
					}
				}
		}
		for(register int i=n;i>=1;--i)
		{
			ans[i] = a[i][n+1] / a[i][i];
		}
	}
	inline int random(int l,int r) {return (ll)rand() * rand() % (r - l + 1) + l;}
	int n;
	inline int equal(double x,double y){return fabs(1.0 * (x - y)) <= eps;}
	inline short main()
	{
		srand((unsigned)time(0));
		ak = scanf("%lld",&n);
		try(i,1,n) ak = scanf("%lf%lf%lf%lf",&d[i].x,&d[i].y,&d[i].lx,&d[i].ly);
//		try(i,1,n) p[i] = i;
//		std::random_shuffle(p+1,p+n+1);
		try(i,1,30)
	//	try(p1,1,n) try(p2,p1+1,n)
		{
			register int p1 = random(1,n),p2 = random(1,n);
			if(p1 == p2) continue;
			memset(a,0.0,sizeof(a)); memset(ans,0.0,sizeof(ans));
			register double x1 = d[p1].x,y1 = d[p1].y,kx = d[p1].lx,ky = d[p1].ly;
			a[1][1] = x1; a[1][2] = -y1; a[1][3] = 1; a[1][4] = 0; a[1][5] = kx;
			a[2][1] = y1; a[2][2] = x1; a[2][3] = 0; a[2][4] = 1; a[2][5] = ky;
			x1 = d[p2].x; y1 = d[p2].y; kx = d[p2].lx; ky = d[p2].ly;
			a[3][1] = x1; a[3][2] = -y1; a[3][3] = 1; a[3][4] = 0; a[3][5] = kx;
			a[4][1] = y1; a[4][2] = x1; a[4][3] = 0; a[4][4] = 1; a[4][5] = ky;
			gss(4);
			register double dx = ans[3],dy = ans[4]; register int cnt = 0;
			try(j,1,n)
			{
				register double c1 = d[j].x * ans[1] - d[j].y * ans[2] + dx,c2 = d[j].y *ans[1] + d[j].x * ans[2] + dy;
				if(equal(c2,d[j].ly) and equal(c1,d[j].lx))
					cnt++;
			}
			if(cnt * 2 >=  n)
			{
				register double csc = ans[1],ssc = ans[2];
				double scale = std::sqrt(csc * csc + ssc * ssc);
				if((ssc / scale ) <= eps) printf("%.10lf\n",pi * 2 - acos(csc / scale));
				else printf("%.10lf\n",acos(csc / scale));
				printf("%.10lf\n",scale);
				printf("%.10lf %.10lf\n\n",dx,dy);
				return 0;
			}
		}
		return 0;
	}
}
signed main() {return xin::main();}
posted @ 2021-08-07 20:30  NP2Z  阅读(39)  评论(0编辑  收藏  举报