Test the way of garlic

Source: Internet
Author: User

Test the way of garlic

Link: http://www.jisuanke.com/minicourse/63

Green energy

It's time to change the world. This time, he will design solar power-off solutions for some harsh terrain environments.

In the latest design, solar panels are set on some solar towers, the same height as the towers.

This time, n tower towers will be set up. These towers have been created in advance, and the height of tower I is h.I. Now engineers need to determine where the tower is to be placed for maximum total energy.

The terrain environment of the tower is represented by a polygon of m points. Each point in a polygon will give the corresponding coordinates (xI, yI), xI <xI + 1.

After measurement, we can see that the radiation angle of the sun in this region is always α degrees. The sun is shining in the upper left corner to the lower right corner. The amount of solar energy obtained depends on the length of the tower exposed to sunlight.

When the two towers are placed close to each other, the shadow of the left Tower will fall onto the right tower, so that the energy produced by the right tower will be reduced to a certain extent. Similarly, the fluctuating terrain around the tower may also block the tower, reducing the obtained energy.

Your task is to design the placement scheme of the tower so that all the towers can obtain as much energy as possible.

Input

The first line of the input file contains three integers: n, m, α (1 ≤ n ≤ 104, 2 ≤ m ≤ 104, 1 ≤ α <90 ).

The second row contains n integers hI, is the height of the tower (1 ≤ hI ≤ 103 ).

Next m behavior xI, yI pair, which is the coordinate of the vertex of the terrain (| xI | ≤ 105, xI <xI + 1, | yI | ≤ 103 ).

Output

The largest possible solar value for the first act of the output file, with an absolute error of no more than 10-6.

The next n rows output the x-point coordinates of the position of the tower. The absolute error cannot exceed 10.-9.

The output sequence of the tower coordinates must be consistent with the input sequence.

If you have multiple solutions to maximize the total value, you can output either of them.

Example 1

Input:

5 4 1020 10 20 15 100 1040 2050 070 30

Output:

52.34288864959254516.00.070.065.365.3

 

Every time I had a math problem, I had a little trouble talking about it. Write again after time;

Reprinted, please specify the Source: search for & STAR kids

 

Elimination of racing cars

Racing competitions are becoming increasingly popular on Pandora planet. But their competition is not the same as we usually do: n racing cars are playing the same game on a long straight track. The speed of each racing car is 1 m/s, and the whole track is marked with coordinates every meter.

In a racing car, racing car I starts from 0 seconds byI to BI mobile. To BI and then returnsI toI mobile. Cyclical.

It's also garlic! It turns out that this is a mobile phone game being played by garlic. Garlic bacteria can put down TNT in some places to blow up some cars. Because he has m problems. Where, question j is: in tJ moment, in xI to yHow many racing cars do I have?

Your task is to answer your question.

Input

The first line of the input contains two numbers: n and m (1 ≤ n, m ≤ 1000), representing the number of racing cars and the number of garlic problems.

In the next n rows, each row contains two integers,.I, BI (0 ≤I, BI ≤ 109,I! = B(I) represents the start point and the end point of racing car I.

In the next m row, each row contains three integers xJ, yJ, tJ (0 ≤ xJ ≤ yJ ≤ 109, 0 ≤ tJ ≤ 109), representing the left and right coordinate boundary of question j and the time of inquiry respectively.

Output

The output contains a total of m rows, each of which has an integer representing the answers to the corresponding m questions.

Example 1

Input:

5 50 10 22 33 54 50 5 00 1 20 2 12 5 22 5 3

Output:

51243

 

Calculate the parking position of each State (Time Point) (pay attention to the start direction)

Reprinted, please specify the Source: search for & STAR kids

#include<stdio.h>#define LL long longstruct car{    LL a;    LL b;} num[1005];LL ffabs(LL x){    if(x<0)return -x;    else return x;}int main(){    LL n,m;    LL x,y,t;    scanf("%lld%lld",&n,&m);    for(int i=0; i<n; i++)    {        scanf("%lld%lld",&num[i].a,&num[i].b);    }    for(int i=0; i<m; i++)    {        scanf("%lld%lld%lld",&x,&y,&t);        LL ca=0;        for(int j=0; j<n; j++)        {            if(num[j].a<num[j].b)            {                if(num[j].a>y||num[j].b<x) continue;                if(num[j].a>=x&&num[j].b<=y)                {                    ca++;                    continue;                }                else                {                    LL sum=-1;                    if(t==0)                    {                        sum=num[j].a;                    }                    else if(t<=num[j].b-num[j].a)                    {                        sum=num[j].a+t;                    }                    else                    {                        LL s=t/ffabs(num[j].b-num[j].a);                        LL tp=t%ffabs(num[j].b-num[j].a);                        if(s%2==0)                        {                            sum=num[j].a+tp;     //                       if(tp==0)sum=num[j].b;                        }                        else                        {                            sum=num[j].b-tp;      //                      if(tp==0)sum=num[j].a;                        }                    }                    if(sum>=x&&sum<=y)ca++;                }            }            else            {                if(num[j].a<x||num[j].b>y) continue;                if(num[j].b>=x&&num[j].a<=y)                {                    ca++;                    continue;                }                else                {                    LL sum=-1;                    if(t==0)                    {                        sum=num[j].a;                    }                    else if(t<=ffabs(num[j].a-num[j].b))                    {                        sum=num[j].a-t;                    }                    else                    {                        LL s=t/ffabs(num[j].b-num[j].a);                        LL tp=t%ffabs(num[j].b-num[j].a);                        if(s%2==0)                        {                            sum=num[j].a-tp;  //                          if(tp==0)sum=num[j].b;                        }                        else                        {                            sum=num[j].b+tp;  //                          if(tp==0)sum=num[j].a;                        }                    }                    if(sum>=x&&sum<=y)ca++;                }            }        }        printf("%lld\n",ca);    }    return 0;}


 

Replacement joke

Little garlic is naughty again. This time, my sister's lab reports were poisoned.

My sister's lab report originally records the sequence from 1 to n, and any two numbers are separated by spaces. However, the space between the numbers is deleted by the garlic in qijie, and the entire sequence of numbers is changed to a number string with a length of 1 to 100 and no space in the header.

Now my sister is angry. I am asking you to write a program to restore the test data.

Input

There is a line in the input file, which is a string-experiment data that is messed up by garlic.

The length of a string is between 1 and 100.

Output

The output contains a line of raw test data-1 to n.

There is a space between any two data.

If there are multiple groups of correct solutions that meet the requirements, output any of them.

Example 1

Input:

4111109876532

Output:

4 1 11 10 9 8 7 6 5 3 2

 

Train of Thought: Deep Search; Tips: first find the maximum value based on the length of the string, first search for two digits;

Reprinted, please specify the Source: search for & STAR kids

#include<stdio.h>#include<string.h>char ch[105];bool vc[105];bool vis[105];int num[105];int mmax;int len;bool flag=false;int ttt=0;void dfs(int k,int t){    if(flag) return ;    num[t]=k;    int tt=ch[k]-'0';    if(k+1<len)    {        int tp=(ch[k]-'0')*10+ch[k+1]-'0';        if(tp<=mmax&&!vis[tp]&&!vc[k]&&!vc[k+1])        {//           printf("--------------------\n");            vis[tp]=true;            vc[k]=true;            vc[k+1]=true;            dfs(k+2,t+1);            vis[tp]=false;            vc[k]=false;            vc[k+1]=false;        }        if(t==mmax&&k>=len){flag=true; return;}    }    if(!vis[tt]&&!vc[k]&&tt<=mmax&&k<len)    {        vis[tt]=true;        vc[k]=true;        dfs(k+1,t+1);        vis[tt]=false;        vc[k]=false;    }    if(t==mmax&&k>=len){flag=true; return;}}int main(){    scanf("%s",ch);    len=strlen(ch);    if(len<10) mmax=len;    else    {        mmax=9+(len-9)/2;    }    num[0]=1;    memset(vis,false,sizeof(vis));    memset(vc,false,sizeof(vc));    dfs(0,0);    if(flag)    {        for(int i=0,j=1; i<len; i++)        {            if(i==num[j])            {                printf(" ");                j++;            }            printf("%c",ch[i]);        }    }    return 0;}/*111108569742311110852974231102345678911*/


Scammers

In view of the congested traffic conditions in our city, the Municipal Traffic Management Department decided to place an automatic parking Toll System on both sides of the road after hearing. When a vehicle enters a parking space, the system uses a camera to take a picture of the vehicle. It identifies the vehicle by recognizing the numbers and letters on the license plate, connects the vehicle information database of the vehicle management office to confirm the vehicle, and deducts fees.

This is where you can play well...

Some car owners block one or more numbers and letter sequences on the license plate when parking, to hinder the identification of the identification system, in order to avoid the payment of parking fees.

The car owner is simply using a gentle block to create a difficult world ?! Management is on the one hand, and technical solutions are king.

Such a difficult project had to be handed over to the computer lab. D. God is responsible for color recognition. E. God is responsible for model recognition. The possible range of license plates is reduced a little bit. As an intern, it is also an arduous task to screen license plate information that already exists in the vehicle database that matches the current known information. This is the first step of the project, I won't say much about the importance. Come on.

Input

The first line of the input file contains a string of 9 characters, which indicates recognition.

The recognizable characters are displayed by uppercase letters and numbers, and "*" indicates the characters that are not recognized due to occlusion.

The second line of the input file contains an integer n (1 ≤ n ≤ 1000)-the number of license information in the motor vehicle database.

The next n lines will contain the corresponding license information, one for each line.

The license information is a string of 9 Characters containing only numbers and uppercase letters. All license information must be different.

Output

The first act of the output file is an integer k (0 ≤ k ≤ n) -- number of licenses that meet the given requirements.

The next k lines output all possible license information.

Example 1

Input:

A**1MP19*4A001MP199E885EE098A111MP199KT7351TTB

Output:

2A001MP199A111MP199

 

Violent!

Reprinted, please specify the Source: search for & STAR kids

#include<stdio.h>#include<string.h>char ans[1005][15];int main(){    char tp[15],num[15];    int n,ca=0;    scanf("%s",num);    scanf("%d",&n);    while(n--)    {        scanf("%s",tp);        bool bo=true;        for(int i=0;i<9;i++)        {            if(num[i]=='*') continue;            if(num[i]!=tp[i]){bo=false;break;}        }        if(bo){strcpy(ans[ca++],tp);}    }    printf("%d\n",ca);    for(int i=0;i<ca;i++)    printf("%s\n",ans[i]);    return 0;}


 

 

 

 

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.