週末に来てメーデーの週試合をします.

11769 ワード

テーマリンク:http://acm.nefu.edu.cn/JudgeOnline/contestShow.php 転送ドア:nefu
1. Rotate Circule 
タイトルの説明:
Rotate Circule
Problem:A
Time Limit:1000 ms
メモリLimit:65535 K
Description

I know you are very smart and good at math. But how about the analytic geometry. For example, if I give you a compass and you can easily draw a circle of radius R at point P(x, y). However, I can only give you a circle of radius R at point O(x1, y1) now. How to get a circle whose center at P-point and radius is R. We can ensure that P-point and O-point do not overlap. You can only use one kind of operation to make the circle rotate any angle around any point which at the border of the circle. So you can make the circle rotate to P-point by using the circle at O-point after some operation. What is the minimum number of operation to do this . 
          _ 1


( operation of rotating around point at border )
Input

There are several test cases.
Each test case contains 5 positive integers R , x , y , x1 , y1 as the description in one line. ( R ≤ 1000 , 0 ≤ x ,y ≤100,000,000 and 0 ≤ x1 , y1 ≤ 100,000,000 ).
The input will finish with the end of file.
Output

For each the case, your program will output one positive integers indicate the answer.
Sample Input

5 47 72 97 8
4 44 38 32 79
Sample Output

9
6
タイトルの :
コンパスがあると の と の を くことができますが、 Oと Rの しか られていません.だから、 の の を る で、 Pと Rの を て、 の を にします.
テーマ :
を にするためには、OPラインの に って の さで する があります.すなわち、 の さは の です. の に しては を うべきです. を って な を して、ちょうどP に を とすことができます.したがって、 が な は、 に してプラス1になる.
コードの :
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

int main()
{
    long long x,y,x1,y1;
    int r;
    long long num=0;
    while(scanf("%d%lld%lld%lld%lld",&r,&x,&y,&x1,&y1)!=EOF)
    {
        long long d=(long long)sqrt((x1-x)*(x1-x)+(y1-y)*(y1-y));
        num=(long long)d/(2*r);
        printf("%lld
",num+1); } return 0; }
2. Cut The Cake:
タイトル:
Cut The Cake
Problem:F
Time Limit:1000 ms
メモリLimit:65535 K
Description

Today is Julia's birthday, she was so delightful that she decided to buy a big cake and celebrate with her friends. The cake is circular in shape. Now a total of n people will eat the cake, so Julia cut the cake equally into n shares. But m persons say they want to eat the cake too. So now there are n + m people want to eat the cake. Please answer, how many times at least can Julia cut n pieces of cakes equally into n+m pieces? (Julia can only cut from the center of the circle to circumference, put several pieces of cakes together can be seen as one piece)
Input

a number t will be input on the first line, then t lines will be follow.
Each line will contain two integers n and m.
1&lt;=t &lt;=10000, 1&lt;=n,m&lt;=1000
Output

For each case, output the minimum times of cut in one line.
Sample Input

2
2 1
3 1
Sample Output

2
3
タイトルの :
ケーキは が で、 はn がいましたが、 でm が ました.n からn+m まであと のケーキを りますか?
テーマ :
ケーキの からケーキのエッジまでの はナイフで めています.そして の もケーキをナイフで りました.そしてこのナイフはケーキを けていません. を して、 な を とすることによって、 な の を します. えば、6 (60 の )がいて、また9 (40 の )が て、 できる の は120 、240 、360 (0 )です.だから、 る の は6+9-gcd(6,9)です.ですから、この に な の はm+n-gcd(m,n)です.
コードの :
#include <iostream>

using namespace std;
int gcd(int a,int b)
{
    if(!b)
    return a;
    else
    return gcd(b,a%b);
}
int main()
{
   int t;
   int n,m;
   cin>>t;
   while(t--)
   {
       cin>>n>>m;
       m=m+n;
       if(m%n==0)
       cout<<m-n<<endl;
       else
       {
           if (gcd(m,n)==1)
           cout<<m-1<<endl;
           else
           cout<<m-gcd(m,n)<<endl;
       }
   }
    return 0;
}
3.Lazy People:
タイトル:
Lazy People
Problem:I
Time Limit:1000 ms
メモリLimit:65535 K
Description

On a flat map, there are n straight lines ,which divide the map into many regions, two regionsare adjacent if and only if they have a common boundary edges. Walk from one region to its adjacent region cost exactly only one unit of energy.You can’t walk from one to another if this two regions is not adjacent.
SmallSmallBule's home is on Point P. Every day,he needs to go to school which is located at Point Q, P and Q are located in different regions. Since SmallSmallBlue is very lazy,he wants to know what is the minimum units of  energy to be  cost to go to school from home. Now,he needs your help to calculate the answer.
Input

the first line has a number T,(T&lt;=22),which is the number of testcases.
for each testcase,the first line has two integers xs,ys(-10^6&lt;=xs,ys&lt;=10^6),,which is the  location of SmallSmall blue's home.
the second line has two integers xh,yh(-10^6&lt;=xh,yh&lt;=10^6),which is the location of school.
the third line has a number n(n&lt;=400),which is the number of straight lines. then the next n lines,each line has three integers,ai,bi,ci,(-10^6&lt;=ai,bi,ci&lt;=10^6) which are to represent the straight line ai*x+bi*y+c=0.
Output

for each testcase,you need to output one line which contains only one integer,
which is the minimum units of energy to be cost to go from home to school.
Sample Input

2
2 2 
-2 -2
2
0 2 0
2 0 0

3 3 
-3 -3
3
0 2 0
1 0 1
1 0 -1
Sample Output

2
3
ベント

In the first test case,two lines is x=0 and y=0, home is (2,2), school is (-2,-2), so he needs to use up 2 units of energy.(he uses up first unit of energy by arriving at the first region which (-1,1) or (1,-1) belongs to, and uses up second unit of energy by arriving at the second region which the school belongs to)
タイトルの :
の と の をすでに っていて、n の がまだあって、 の の の を の に けることができて、 の にまたがるごとに1マスのエネルギーを って、 なくとも するエネルギーの を めます.
テーマ :
と という とn の を すればいいです. は2つの の を に ち んでいくことです.2つの を け わせると=0となり、 の があると します. <0なら、2 を の に します.
に してください.この はデータ に します. と の は10^6 です.しかし、ポイントを に ち んでから られるのは つのlong longタイプしか できない の です.だから、long long long でデータ をしなければなりません.そうでないとWAになります.
コードの :
#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

long long a[420],b[420],c[420];
int main()
{
    long long T;
    long long xs,ys,xh,yh;
    long long n;
    scanf("%lld",&T);
    memset(a,0,sizeof(a));
    memset(b,0,sizeof(b));
    memset(c,0,sizeof(c));
    while(T--)
    {
        scanf("%lld%lld%lld%lld",&xs,&ys,&xh,&yh);
        scanf("%lld",&n);
        memset(a,0,sizeof(a));
        memset(b,0,sizeof(b));
        memset(c,0,sizeof(c));
        for(int i=0;i<n;i++)
        {
            scanf("%lld%lld%lld",&a[i],&b[i],&c[i]);
        }
        int num=0;
        for(int i=0;i<n;i++)
        {
            if(((a[i]*xs+b[i]*ys+c[i])*(a[i]*xh+b[i]*yh+c[i]))<0)
            {
                num++;
            }
        }
        printf("%d
",num); } return 0; }
4.Max a&b:
Max a&b
Problem:B
Time Limit:3000 ms
メモリLimit:65536 K
Description

Now give you n positive integers. You can select two integers from n integers, and calucate the (a&amp;b). ‘&amp;’ is a binary operator.For example, 5&amp;6=4. 
Now I need you calculate the maximum value of (a&amp;b).
Input

There are multiple test cases.
For each test case.The first line contains one integer n(n&lt;=300000), which indicates the number of integers.
The following n lines. The ith line contains one positive integer ai.(ai&lt;=10^9)
Output

For each test case, your program will output the maximum value of a&amp;b.
Sample Input

3
2
8
10
Sample Output

8
タイトルの :
n の を え、 の2つの の を めます.
テーマ :
から までの りで すればいいです.この は と して、このコードはあまり くないです. えば、 つの の&0なら、コードは されませんでした.しかし、できました. の いです.もちろん する があります. な えは に べ えて、それから の めから して、 の2 の を してください. つの の が じでないと、& した の は ずしも とは らないので、 から と ろから という つの の&その の と して、 を するだけでなく、 を して、このように していきます.
コードの :
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>

using namespace std;

long long a[300010];
int bit[300010];
int main()
{
    int n;
    long long maxx,t;
    int b;
    long long x;
    int xb;
    while(scanf("%d",&n)!=EOF)
    {
        memset(a,0,sizeof(a));
        memset(bit,0,sizeof(bit));
        for(int i=0; i<n; i++)
        {
            scanf("%lld",&a[i]);
        }
        //cout<<"dsyhfg"<<endl;
        sort(a,a+n);
        for(int i=0;i<n;i++)
        {
            t=a[i];
            while(t>0)
            {
                t/=2;
                bit[i]++;
            }
        }
        for(int i=n-1; i>=0; i--)
        {
            if(bit[i]==bit[i-1])
            {
                printf("%lld
",a[i]&a[i-1]); break; } else { maxx=a[i]&a[i-1]; b=0; t=maxx; while(t>0) { t/=2; b++; } x=a[i-1]&a[i-2]; t=x; xb=0; while(t>0) { t/=2; xb++; } if(b>xb) { //cout<<"111hdgfj"<<endl; printf("%lld
",maxx); break; } else if(b==bit[n-2]) { //cout<<"222hdgfj"<<endl; if(x>maxx) { maxx=x; b=xb; } } else if(b<bit[n-2]) { //cout<<"333hdgfj"<<endl; maxx=x; b=xb; } } } } return 0; }