1106 Transmitters

向量的叉乘大于0即是在直线的同一边。

#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstdio>


using namespace std;

struct point{
	double x;
	double y;

}p[1000],center;

int tmax(int a, int b){
	return a>b?a:b;
}

double dis(point a,point b){	//d^2
	return (a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y);
}

double multi(point a,point b,point o){		//叉乘 a*d-b*c
	return(a.x-o.x)*(b.y-o.y)-(a.y-o.y)*(b.x-o.x);
}

int main(){
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);

	int n;
	double r;

	while(cin>>center.x>>center.y>>r && r>=0){
		int result = 0;

		cin>>n;

		for(int i=0;i<n;i++){
			cin>>p[i].x>>p[i].y;
		}

		for(int k=0;k<n;k++){
			int count1 = 0;
			int count2 = 0;
			if(dis(p[k],center)<=r*r){
				

				for(int j=0;j<n;j++){
					if(dis(p[j],center)<=r*r){
						if(multi(p[k],p[j],center)>0)
							count1++;
						else
							count2++;
					}
				}
			
				
			}
			result = tmax(result,tmax(count1,count2));
		}

		
		cout<<result<<endl;
		
	}


	return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
解释:target = self.survey.source.target collection = self.survey.source.collection '''Mesh''' # Conductivity in S/m (or resistivity in Ohm m) background_conductivity = 1e-6 air_conductivity = 1e-8 # Permeability in H/m background_permeability = mu_0 air_permeability = mu_0 dh = 0.1 # base cell width dom_width = 20.0 # domain width # num. base cells nbc = 2 ** int(np.round(np.log(dom_width / dh) / np.log(2.0))) # Define the base mesh h = [(dh, nbc)] mesh = TreeMesh([h, h, h], x0="CCC") # Mesh refinement near transmitters and receivers mesh = refine_tree_xyz( mesh, collection.receiver_location, octree_levels=[2, 4], method="radial", finalize=False ) # Refine core mesh region xp, yp, zp = np.meshgrid([-1.5, 1.5], [-1.5, 1.5], [-6, -4]) xyz = np.c_[mkvc(xp), mkvc(yp), mkvc(zp)] mesh = refine_tree_xyz(mesh, xyz, octree_levels=[0, 6], method="box", finalize=False) mesh.finalize() '''Maps''' # Find cells that are active in the forward modeling (cells below surface) ind_active = mesh.gridCC[:, 2] < 0 # Define mapping from model to active cells active_sigma_map = maps.InjectActiveCells(mesh, ind_active, air_conductivity) active_mu_map = maps.InjectActiveCells(mesh, ind_active, air_permeability) # Define model. Models in SimPEG are vector arrays N = int(ind_active.sum()) model = np.kron(np.ones((N, 1)), np.c_[background_conductivity, background_permeability]) ind_cylinder = self.getIndicesCylinder( [target.position[0], target.position[1], target.position[2]], target.radius, target.length, [target.pitch, target.roll], mesh.gridCC ) ind_cylinder = ind_cylinder[ind_active] model[ind_cylinder, :] = np.c_[target.conductivity, target.permeability] # Create model vector and wires model = mkvc(model) wire_map = maps.Wires(("sigma", N), ("mu", N)) # Use combo maps to map from model to mesh sigma_map = active_sigma_map * wire_map.sigma mu_map = active_mu_map * wire_map.mu '''Simulation''' simulation = fdem.simulation.Simulation3DMagneticFluxDensity( mesh, survey=self.survey.survey, sigmaMap=sigma_map, muMap=mu_map, Solver=Solver ) '''Predict''' # Compute predicted data for your model. dpred = simulation.dpred(model) dpred = dpred * 1e9 # Data are organized by frequency, transmitter location, then by receiver. # We had nFreq transmitters and each transmitter had 2 receivers (real and # imaginary component). So first we will pick out the real and imaginary # data bx_real = dpred[0: len(dpred): 6] bx_imag = dpred[1: len(dpred): 6] bx_total = np.sqrt(np.square(bx_real) + np.square(bx_imag)) by_real = dpred[2: len(dpred): 6] by_imag = dpred[3: len(dpred): 6] by_total = np.sqrt(np.square(by_real) + np.square(by_imag)) bz_real = dpred[4: len(dpred): 6] bz_imag = dpred[5: len(dpred): 6] bz_total = np.sqrt(np.square(bz_real) + np.square(bz_imag)) mag_data = np.c_[mkvc(bx_total), mkvc(by_total), mkvc(bz_total)] if collection.SNR is not None: mag_data = self.mag_data_add_noise(mag_data, collection.SNR) data = np.c_[collection.receiver_location, mag_data] # data = (data, ) return data
最新发布
06-01

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值