关键的考虑是名缰利锁,

作业1

用d做半径,小岛的点做圆心,圆和x轴上结识获得的间隔正是足以包罗这些小岛的radar,能够存在的坐席。

选择题:

 

1.  C

排序,找到最多重叠点或区间,拿到答案。

 

 

编程题:

数量之中很反常,有d为负的处境。

1.

 

代码:

在qsort的时候要小心因为用的是浮点数。

 

 

#include<iostream>

笔者是在wa了很频仍过后终于过了……

#include<cstdio>

 

#include<cmath>

#include <iostream>
#include<math.h>
#include<algorithm>
using namespace std;

#include<algorithm>

typedef struct sea
{
 int x;
 int y;
} Sea;
typedef struct Radar
{
 double Rm;
 double Lm;
} Rader;

#include<climits>

int comp(const void *p1, const void *p2)
{
   Radar I1 = *(Radar *)p1;
   Radar I2 = *(Radar *)p2;
   double temp = I1.Rm – I2.Rm;
   if (temp > 0.0) return 1;
   else if (temp < 0.0) return -1;
}

 

int main()
{
 int n,d;
 int count=1;
 while(cin>>n>>d&&n!=0&&d!=0)
 {
  bool index=false;
  int ans=1;
  Sea *island=new Sea[n+1];
  Rader *radar=new Rader[n+1];
  for(int i=0;i<n;i++)//inital
  {
   cin >>island[i].x >>island[i].y;
  }
  if(d<0)
  {
                cout<<“Case “<<count<<“:
“<<“-1″<<endl;
    delete [] island;
    delete [] radar;
    index=true;
    count++;
       index=true;
  }
  if(index)
   continue;
  for(int i=0;i<n;i++)
  {
   double temp;
   if((d*d-(island[i].y*island[i].y))>=0)
   temp=sqrt(double(d*d-(island[i].y*island[i].y)));
   else
   {
    cout<<“Case “<<count<<“:
“<<“-1″<<endl;
    delete [] island;
    delete [] radar;
    index=true;
    count++;
    break;
    
   }
   radar[i].Rm=island[i].x+temp;
   radar[i].Lm=island[i].x-temp;

using namespace std;

  }

 

  if(index)
   continue;

int isPrime(int n){

  qsort(radar,n,sizeof(radar[0]),comp);//排序

         int i,j; 

  double ml,mr;
  ml=radar[0].Lm;
  mr=radar[0].Rm;
  for(int  i=1;i<n;i++)
  {
   if(radar[i].Lm<=mr)
   {
    if(ml<radar[i].Lm)
     ml=radar[i].Lm;
    if(radar[i].Rm<mr)
     mr=radar[i].Rm;
   }
   else
   {
    ml=radar[i].Lm;
    mr=radar[i].Rm;
                ans++;
   }
  }
  cout<<“Case “<<count<<“: “<<ans<<endl;
  delete [] island;
  delete [] radar;
  count++;
  scanf(“n”);
 }
 return 0;
}

         if(n==2){

                   return true;

         }

         else if (n<2||n%2==0){

                   return false;

         }

         else{

                   j = (int)sqrt(n+1);

             for (i=3;i<=j;i=i+2)

                      if (n%i==0)

                      return false;

         }

         return true;

}

 

int main(){

        

         int count = 0;

        

      for(int i=101; i<200; i++){

           if(isPrime(i)){

                    cout<<i<<” “;

                    count+=1;

           }

      }

      cout<<endl;

      cout<<count<<endl;

      return 0;

      //24747380@qq.com

}

 

 

运营结果:

 澳门新葡萄京官网注册 1

 

 

2.

Jack和露丝是一对爱人,他们每一日都会玩多个数字游戏,游戏准绳如下:

【1】       Jack从间隔[a,b],中随机选择三个数字x

【2】       露丝从间隔[c,d],中随机接收八个数字x

【3】       若是(x+y卡塔尔(قطر‎mod p = m ,他们就能够出外看电影

【4】       不然就在体育场所学习

给定整数a,b,c,d,p,m他们想通晓外出看摄像的票房价值。

 

代码:

 

#include<iostream>

#include<cstdio>

#include<cmath>

#include<algorithm>

#include<climits>

 

using namespace std;

int main(){

         int t;

         cin>>t;

         while(t–){

                   int a,b,c,d,p,m;

                   int count = 0;

                   int res;

                  
cin>>a>>b>>c>>d>>p>>m;

                   for(int x=a; x<=b; x++) {

                            for(int y=c; y<=d; y++){

                                     if((x+y)%p==m){

                                               count++;

                                     }

                            }

                   }

                   res = ((b-a+1)*(d-c+1));

                   if (count==0){

                           
cout<<0<<“/”<<1<<endl;

                   }

                   else{

                            for(int i=2;i<=count;i++)

                             if(count%i==0 && res%i==0){

                                   count/=i;

                                   res/=i;

                                   i–;      

                              }

                           
cout<<count<<“/”<<res<<endl;      

                   }       

         }

        

         return 0;

}

运营结果:

 澳门新葡萄京官网注册 2