zoukankan      html  css  js  c++  java
  • 临时文档

    #include <iostream>
    #include <cmath>
    #include <map>
    using namespace std;
    const int prime=1999;
    
    struct point{
    int x,y;
    }p[1001];
    
    struct hashtable{
    int value;
    map<int,int> mymap;
    }myhash[prime];
    
    void setHash(int x,int y){
    	int h= (x*x+y*y) % prime; 
    	myhash[h].value=1;
    	myhash[h].mymap.insert(pair<int, int>(x, y));
    
    
    }
    bool Search(int x,int y)  
    {	map<int,int>::iterator ptr;
    	
        int h = (x*x+y*y) % prime;  
    	if(myhash[h].value!=1)return false;
    	ptr=myhash[h].mymap.find(x);
    	int tt=(*ptr).second;
    	if(tt==y)return true;
        return false;
    }  
    int work(int n){
    	int i,j;
    	int sum=0;
     for(i=1;i<n;i++)
    	 for(j=i+1;j<=n;j++)
    	 {
    			int x1 = p[i].x - (p[i].y - p[j].y);  
                int y1 = p[i].y + (p[i].x - p[j].x);  
                int x2 = p[j].x - (p[i].y - p[j].y);  
                int y2 = p[j].y + (p[i].x - p[j].x);  
                if(Search(x1,y1) && Search(x2,y2)) sum++;  
    			
    	 
    	 }
    	 for(i=1;i<n;i++)
    		 for(j=i+1;j<=n;j++){
    	 int x3 = p[i].x + (p[i].y - p[j].y);  
                int y3 = p[i].y - (p[i].x - p[j].x);  
                int x4 = p[j].x + (p[i].y - p[j].y);  
                int y4 = p[j].y - (p[i].x - p[j].x);  
                if(Search(x3,y3) && Search(x3,y3)) sum++; 
    		 }
    	 return sum/4;
    
    }
    int main(){
    
    int n;
    
    while(1){
    	cin>>n;
    	if(n==0)break;
    	for(int j=0;j<prime;j++){
    	myhash[j].value=-1;
    	}
    	for(int i=1;i<=n;i++){
    		cin>>p[i].x>>p[i].y;
    		setHash(p[i].x,p[i].y);
    	}
    	cout<<work(n)<<endl;
    
    }
    return 0;
    }

    版权声明:本文为博主原创文章,未经博主允许不得转载。

    today lazy . tomorrow die .
  • 相关阅读:
    ROSS仿真系统简单教程
    python小练习1.1
    c语言文件I/O 文件读取和写入
    Python 学习笔记 多线程-threading
    parsec(The parsec benchmark suit )使用教程
    Checkpoint/Restore In Userspace(CRIU)使用细节
    Checkpoint/Restore in Userspace(CRIU)安装和使用
    考研总结
    北理计算机复试经验
    PAT(A) 1075. PAT Judge (25)
  • 原文地址:https://www.cnblogs.com/france/p/4808747.html
Copyright © 2011-2022 走看看