FJNU2016-2017 20th Annual Junior Program Design Competition (official competition)

Source: Internet
Author: User
Tags min mul stdin first row time limit
problem A: run faster than anyone else idrandom

As we all know, Idrandom is a fast-running Dalao. But for all the unspeakable reasons, it was not until this year that he enrolled in his beloved marathon.

One night, he and his sister ran at the Eastern Stadium (Hush), and the eastern Stadium was a standard 400-metre track. Originally, Idrandom and his sister from the same position, along the track and field of the most inner circle at the same time to start running, but idrandom giant run quite fast, not long before Idrandom giant ran away.

After starting the run T-second, Idrandom suddenly had a new idea, and he wanted to sit down and chat with her sister in the stadium. Looking at the stadium of the vast crowd, idrandom giant did not see his sister where. He wanted to know that if he stopped right now, his sister would keep running at the same pace, and how long after his sister would run to his present position.

Idrandom's running speed is V1 (m/sec), and his sister runs at V2 (m/sec), and we assume that the two of them are graceful enough to avoid the other students on the runway, so their speed remains the same. At the same time they always run in the most inner lap of the runway, so it can be thought that they always run at 400 meters per lap on the runway.

Input

There are multiple sets of test data

The first line is given an integer t, which indicates the number of data groups

Then there will be T-line, each line has three integers t,v1,v2, the meaning is the same as the title.

(0< v2 < v1,v1*t<2^30)

Output

Depending on the test input, each line outputs an answer that is accurate to 2 digits after the decimal point.

Sample Input
3
100 20 15
100 20 10
200 20 10

Sample Output
6.67
20.00
0.00

#include <bits/stdc++.h> using namespace std; #define for (I,n) for (int. i=1;i<=n;i++) #define FORK (I,k,n) for (int. i=k;i<=n;i++) #define REP (i,n) for (int i=0;i< n;i++) #define ForD (I,n) for (int. i=n;i;i--) #define FORKD (I,k,n) for (int. i=n;i>=k;i--) #define REPD (i,n) for (int i=n;i& gt;=0;i--) #define FORP (x) for (int p=pre[x];p, p=next[p]) #define FORPITER (x) for (int &p=iter[x];p; p=next[p]) #defin
E Lson (o<<1) #define Rson ((o<<1) +1) #define MEM (a) memset (A,0,sizeof (a));
#define MEMI (a) memset (A,127,sizeof (a));
#define MEMI (a) memset (A,128,sizeof (a)); #define INF (2139062143) #define F (1000000007) #define PB push_back #define MP Make_pair #define FI First #define SE sec Ond #define VI vector<int> #define PI pair<int,int> #define SI (a) ((a). Size ()) #define PR (Kcase,ans) printf ("
Case #%d:%i64d\n ", Kcase,ans); #define PRI (A,n) for (i,n-1) cout<<a[i]<< ";
cout<<a[n]<<endl;
                   #define PRI2D (A,n,m) for (i,n) {\     for (j,m-1) cout<<a[i][j]<< "; \ cout<<a[i][m]<<endl; \} #pragma COMMENT (linker, "/stack:102400000,102400000") #define ALL (x) (x). Begin (), (x). End () Ty
Pedef Long Long ll;
typedef long double LD;
typedef unsigned long long ull;  LL Mul (ll A,ll b) {return (a*b)%F;} ll Add (ll A,ll b) {return (a+b)%F;} ll Sub (ll A,ll b) {return ((a)%f+f)%F; void Upd (LL
    &a,ll b) {a= (a%f+b%f)%F;} int read () {int x=0,f=1; char Ch=getchar ();
    while (!isdigit (CH)) {if (ch== '-') f=-1; Ch=getchar ();}
    while (IsDigit (ch)) {x=x*10+ch-' 0 '; Ch=getchar ();}
return x*f;
    } int main () {///Freopen ("A.in", "R", stdin);//Freopen (". Out", "w", stdout);
    int T=read ();
        while (t--) {ll t=read (), V1=read (), V2=read ();
        ll c=t* (V1-V2);
        c%=400;
        Double p=c/(double) v2;
    printf ("%.2lf\n", p);
} return 0;
 }
problem B: Win

112 is FJNUACM assigned to the laboratory, it is well known that there are many dalao, such as flag, such as Nightlemon. At last, Flag won the trophy with its own strength. So he took the trophy to the lab. caused a reign. Because except a few dalao other people are very weak, but everyone wants to hold a cup, and all want to win first, so in order to order the argument. Flag finally put forward a way is everyone together win, so the 鶸 gave the big guy face, intend to win together. But everyone wanted to get closer to the trophy, so they pulled the trophy in their direction, and the farther away the trophy was, the greater the strength. Now suppose that each person's strength equals his distance from the trophy, then tell you the coordinates of each person and the coordinates of the trophy, and ask the direction of the final trophy.

Input

The first line gives a T (t<=100) Number of groups representing the input data
Next, for each set of input
The first line gives a two integer x0,y0 (|x0|,|y0|<=100) that represents the location of the trophy.
The second line gives an n (1<=n<=100) representing the number of people who want to win.
The next n lines each row gives two integers xi,yi (|xi|,|yi|<=100), representing the coordinates of each person

Output

For each set of test data output one row, contains a vector (AI,BI) that represents the resultant direction of the final trophy
which requires |ai|,|bi| to be as small as possible integers. Ai,bi separated by a space, can not have line end space

Sample Input
3
0 0
1
0 1
0 0
2
0 2
2 0
0 1
2
0 1
0 2

Sample Output
0 1
1 1
0 1

Pay attention to the special sentence vector (0,0), the code is not carefully covered I will not send problem C: Wang Lao driver

Wang Lao driver is the name of the old driver in the laboratory, early in the first year to get a driver's license, every summer vacation he will take his family to drive, this year's summer vacation is no exception, Wang old driver this year to take family to Pingtan play, Wang Lao driver's home from Pingtan has two roads, each road has n sections, the two roads of N road length are the same, Each road section of the two roads has a fuel consumption AI and bi (go through the first section of the road, two roads are fuel-guzzling AI and bi), because Wang Lao driver is a skilled old driver, so he can be on any road to change to another road (only allowed at the end of the road), Although the old driver but he can not change the way more than K, because it is easy to be found by the police, Wang Lao driver wants to know how much he needs to spend at least to reach Pingtan.
Note: When Wang Lao driver is at home, he can choose any road of the two roads as a starting point but do not consume his number of lane changes

Input

Contains multiple sets of samples, the first line a number T, indicating the number of samples
For each set of examples:
The first row of two digits n,k, respectively, indicates the number of road segments and the maximum number of times the channel can be changed.
Second row n digits AI represents the fuel consumption of different sections of the first road
The third row n Digital bi represents the fuel consumption of different sections of the second road
(T <=, 1 <= n <= 10000, 0 <= K <=, 0 <= ai <= 1e9, 0 <= bi <= 1e9)

Output

One digit per set of sample outputs, indicating a minimum of consumption

Sample Input
1
6 5
1 4 5 8 9 12
2 3 6 7 10 11

Sample Output
36

HINT
Wang Lao Driver walking route: A1, B2, A3, B4, A5 b6

#include <bits/stdc++.h> using namespace std; #define for (I,n) for (int. i=1;i<=n;i++) #define FORK (I,k,n) for (int. i=k;i<=n;i++) #define REP (i,n) for (int i=0;i< n;i++) #define ForD (I,n) for (int. i=n;i;i--) #define FORKD (I,k,n) for (int. i=n;i>=k;i--) #define REPD (i,n) for (int i=n;i& gt;=0;i--) #define FORP (x) for (int p=pre[x];p, p=next[p]) #define FORPITER (x) for (int &p=iter[x];p; p=next[p]) #defin
E Lson (o<<1) #define Rson ((o<<1) +1) #define MEM (a) memset (A,0,sizeof (a));
#define MEMI (a) memset (A,127,sizeof (a));
#define MEMI (a) memset (A,128,sizeof (a)); #define INF (2139062143) #define F (1000000007) #define PB push_back #define MP Make_pair #define FI First #define SE sec Ond #define VI vector<int> #define PI pair<int,int> #define SI (a) ((a). Size ()) #define PR (Kcase,ans) printf ("
Case #%d:%i64d\n ", Kcase,ans); #define PRI (A,n) for (i,n-1) cout<<a[i]<< ";
cout<<a[n]<<endl;
                   #define PRI2D (A,n,m) for (i,n) {\     for (j,m-1) cout<<a[i][j]<< "; \ cout<<a[i][m]<<endl; \} #pragma COMMENT (linker, "/stack:102400000,102400000") #define ALL (x) (x). Begin (), (x). End () Ty
Pedef Long Long ll;
typedef long double LD;
typedef unsigned long long ull;  LL Mul (ll A,ll b) {return (a*b)%F;} ll Add (ll A,ll b) {return (a+b)%F;} ll Sub (ll A,ll b) {return ((a)%f+f)%F; void Upd (LL
    &a,ll b) {a= (a%f+b%f)%F;} int read () {int x=0,f=1; char Ch=getchar ();
    while (!isdigit (CH)) {if (ch== '-') f=-1; Ch=getchar ();}
    while (IsDigit (ch)) {x=x*10+ch-' 0 '; Ch=getchar ();}
return x*f;
} ll a[10010]={},b[10010]={},f[10010][20][2];
    int main () {//Freopen ("C.in", "R", stdin);//Freopen (". Out", "w", stdout);
    int T=read ();
    int n,k;
        while (cin>>n>>k) {for (I,n) Rep (j,k+1) Rep (l,2) F[i][j][l]=1e15;
        for (I,n) cin>>a[i];

        for (I,n) cin>>b[i];
        F[1][0][0]=A[1],F[1][0][1]=B[1]; LL aNS=1E15;
            Fork (I,2,n) Rep (j,k+1) Rep (l,2) {f[i][j][l]=f[i-1][j][l]+ ((L)? B[i]:a[i]);
            if (j) F[i][j][l]=min (f[i][j][l],f[i-1][j-1][l^1]+ ((L)? B[i]:a[i]));
        if (i==n) ans=min (Ans,f[i][j][l]);

    } cout<<ans<<endl;
} return 0;
 }
Problem D: Task assignment for Konjac Konjac

112 is FJNUACM assigned to the laboratory, it is well known that there are many dalao, such as flag such as Nightlemon. But there are also some konjac konjac, such as Idrandom, this konjac konjac very lazy, always have to drag the last time to complete the task. But his ability is limited, he at the same time anus two things, now, again to some things deadline, he must complete these tasks, you can calculate his shortest finish time.
But Idrandom is too weak, he in ti time to do the first k things are also conditional:
1. If he does nothing at ti time, then he can do it immediately
2. If he was doing two things at ti time, he would never do it.
3. If he is in ti time doing one thing K0, and K0 and K as long as there is any event to have the capacity,
Then it can do the current thing immediately, otherwise it can't.
Now give the time it takes to do everything, and the availability of the matter, and ask for the shortest time to finish.

Input

The first line gives an integer t (1<=t<=100), which represents the number of groups of data
For each set of data
The first line gives an integer n (0 < n<=1000) that represents the number of events to complete
Next n lines, each row gives two integers Costi,fi (1<=costi<=10,0<=fi<=1) representing the first thing
The time required and its scalability, FI 1 for the presence of the capacitive, 0 for non-existent, costi and fi in the middle with a space separated

Output

For each set of data output, a single row, including a number, represents the shortest finish time.

Sample Input
3
2
3 1
4 0
3
4 1
2 0
2 0
3
4 0
3 1
2 1

Sample Output
4
4
5

HINT
is a data n<=20 for 30%. The
n<=500 data for 50%.
for data n<=1000 of 100%.

#include <bits/stdc++.h> using namespace std; #define for (I,n) for (int. i=1;i<=n;i++) #define FORK (I,k,n) for (int. i=k;i<=n;i++) #define REP (i,n) for (int i=0;i< n;i++) #define ForD (I,n) for (int. i=n;i;i--) #define FORKD (I,k,n) for (int. i=n;i>=k;i--) #define REPD (i,n) for (int i=n;i& gt;=0;i--) #define FORP (x) for (int p=pre[x];p, p=next[p]) #define FORPITER (x) for (int &p=iter[x];p; p=next[p]) #defin
E Lson (o<<1) #define Rson ((o<<1) +1) #define MEM (a) memset (A,0,sizeof (a));
#define MEMI (a) memset (A,127,sizeof (a));
#define MEMI (a) memset (A,128,sizeof (a)); #define INF (2139062143) #define F (1000000007) #define PB push_back #define MP Make_pair #define FI First #define SE sec Ond #define VI vector<int> #define PI pair<int,int> #define SI (a) ((a). Size ()) #define PR (Kcase,ans) printf ("
Case #%d:%i64d\n ", Kcase,ans); #define PRI (A,n) for (i,n-1) cout<<a[i]<< ";
cout<<a[n]<<endl;
                   #define PRI2D (A,n,m) for (i,n) {\     for (j,m-1) cout<<a[i][j]<< "; \ cout<<a[i][m]<<endl; \} #pragma COMMENT (linker, "/stack:102400000,102400000") #define ALL (x) (x). Begin (), (x). End () Ty
Pedef Long Long ll;
typedef long double LD;
typedef unsigned long long ull;  LL Mul (ll A,ll b) {return (a*b)%F;} ll Add (ll A,ll b) {return (a+b)%F;} ll Sub (ll A,ll b) {return ((a)%f+f)%F; void Upd (LL
    &a,ll b) {a= (a%f+b%f)%F;} int read () {int x=0,f=1; char Ch=getchar ();
    while (!isdigit (CH)) {if (ch== '-') f=-1; Ch=getchar ();}
    while (IsDigit (ch)) {x=x*10+ch-' 0 '; Ch=getchar ();}
return x*f;
} int a[12345];
Bitset<10001> b;


    int main () {//Freopen ("D.in", "R", stdin);//Freopen (". Out", "w", stdout);
    int T=read ();
    int n;
        while (cin>>n) {int t=0;
        ll Noo=0,c=0;
        B=1;
            for (i,n) {int p=read (), F=read ();
            if (f) a[++t]=p,c+=p;
            else noo+=p; b|= (B&LT;&LT;P);
        } ll Ans=c+noo;
        REP (i,10001) if (B[i]) {ans=min (Ans,max (LL) i,noo+c-i);
    } cout<<max (Ans,noo) <<endl;
} return 0;
 }
problem E: Sundry finishing

Time limit:1000 MS Memory limit:257792 KB
64-bit interger IO Format:%lld Java class Name:main

submit

"Ah .... To move to 112, "said the lazy idrandom.
Because Idrandom is lazy, he puts a lot of things in the lab. Because of this, he had trouble moving things, so he put all his things in a number of boxes of equal size to move the past. But ID June is a person with obsessive-compulsive disorder, he must pile up the box into a number of piles, and follow the following rules whenever he starts to put up a pile of boxes, he will want to put as many boxes as possible in this pile, and make this pile into a self-considered perfect triangle.
The ID thinks the perfect triangle is so defined:
If there is a total of K-level, then from the top down the number I have a box.
For example, if the ID now has 9 boxes:
Put the first pile on a 3-storey perfect triangle, because the 4-storey perfect triangle requires 10 boxes
Put the second pile on a 2-storey perfect triangle, because there are just 3 boxes left.
So he put in two piles altogether.
Now tell you ID how many boxes to set, ask according to the ID June Obsessive-compulsive disorder, ID June will finally heap out how many perfect triangles.

Input

The first line enters an integer T (t<=1000) that represents how many sets of test data
Next T line, each row represents a set of test data, for each set of test data
Enter an integer n (0< n<=1000) that represents the number of boxes that the ID needs to be placed

Output

For each set of test data, output one row, including a number C, representing the number of perfect triangles that the ID June has finally piled up

Sample Input
2
9
3

Sample Output
2
1

#include <bits/stdc++.h> using namespace std; #define for (I,n) for (int. i=1;i<=n;i++) #define FORK (I,k,n) for (int. i=k;i<=n;i++) #define REP (i,n) for (int i=0;i< n;i++) #define ForD (I,n) for (int. i=n;i;i--) #define FORKD (I,k,n) for (int. i=n;i>=k;i--) #define REPD (i,n) for (int i=n;i& gt;=0;i--) #define FORP (x) for (int p=pre[x];p, p=next[p]) #define FORPITER (x) for (int &p=iter[x];p; p=next[p]) #defin
E Lson (o<<1) #define Rson ((o<<1) +1) #define MEM (a) memset (A,0,sizeof (a));
#define MEMI (a) memset (A,127,sizeof (a));
#define MEMI (a) memset (A,128,sizeof (a)); #define INF (2139062143) #define F (1000000007) #define PB push_back #define MP Make_pair #define FI First #define SE sec Ond #define VI vector<int> #define PI pair<int,int> #define SI (a) ((a). Size ()) #define PR (Kcase,ans) printf ("
Case #%d:%i64d\n ", Kcase,ans); #define PRI (A,n) for (i,n-1) cout<<a[i]<< ";
cout<<a[n]<<endl;
                   #define PRI2D (A,n,m) for (i,n) {\     for (j,m-1) cout<<a[i][j]<< "; \ cout<<a[i][m]<<endl; \} #pragma COMMENT (linker, "/stack:102400000,102400000") #define ALL (x) (x). Begin (), (x). End () Ty
Pedef Long Long ll;
typedef long double LD;
typedef unsigned long long ull;  LL Mul (ll A,ll b) {return (a*b)%F;} ll Add (ll A,ll b) {return (a+b)%F;} ll Sub (ll A,ll b) {return ((a)%f+f)%F; void Upd (LL
    &a,ll b) {a= (a%f+b%f)%F;} int read () {int x=0,f=1; char Ch=getchar ();
    while (!isdigit (CH)) {if (ch== '-') f=-1; Ch=getchar ();}
    while (IsDigit (ch)) {x=x*10+ch-' 0 '; Ch=getchar ();}
return x*f;
} int a[1000]={};
    int main () {//Freopen ("E.in", "R", stdin);//Freopen (". Out", "w", stdout);
    int T=read ();
    a[0]=0;
    for (i,1000) a[i]=a[i-1]+i;
    int n;
        while (cin>>n) {int p=0;
            while (n) {int c=upper_bound (a+1,a+1+1000,n)-a-1; N-=A[C];
        ++p;
    } cout<<p<<endl; } rEturn 0;
 }
problem F: Match stick

There are a lot of matches on the flag giant's table. The match rods were placed in a decimal number.

The pendulum of each digit letter with a match stick is shown below.

This decimal number has n bits. One day, the flag giant wanted to rearrange the train rods. He likes the wonderful numbers, so he hopes that the new number is a palindrome number (such as 12321,1221 are palindrome number, 1231 is not a palindrome number), and to exactly use up all the matches stick. He also likes big numbers, so he wants to make the new numbers as big as possible. Now that we know the numbers of the match rods, can you find out what the maximum number of palindrome the match sticks can arrange?

Input

The first line is given an integer t, which represents the number of test data groups
Then each line of the T line is given an n-bit decimal number (1<=n<=10000), which represents the number of the match stick originally arranged.

Output

According to the input data, each line outputs a decimal number, which indicates the maximum number of palindrome that these match bars can arrange.

Sample Input
3
2
4
8

Sample Output
5
11
171

HINT

The number of matches required for each number corresponds to the figure in the title.

for the sample input, the originally arranged number is ' 2 ', a total of 5 matches stick, can be arranged out of the largest palindrome number is 5.

It's not hard to see that only 5,1,7 is used.
The answer may be 5,11111111,711171117,1117111.

#include <bits/stdc++.h> using namespace std; #define for (I,n) for (int. i=1;i<=n;i++) #define FORK (I,k,n) for (int. i=k;i<=n;i++) #define REP (i,n) for (int i=0;i< n;i++) #define ForD (I,n) for (int. i=n;i;i--) #define FORKD (I,k,n) for (int. i=n;i>=k;i--) #define REPD (i,n) for (int i=n;i& gt;=0;i--) #define FORP (x) for (int p=pre[x];p, p=next[p]) #define FORPITER (x) for (int &p=iter[x];p; p=next[p]) #defin
E Lson (o<<1) #define Rson ((o<<1) +1) #define MEM (a) memset (A,0,sizeof (a));
#define MEMI (a) memset (A,127,sizeof (a));
#define MEMI (a) memset (A,128,sizeof (a)); #define INF (2139062143) #define F (1000000007) #define PB push_back #define MP Make_pair #define FI First #define SE sec Ond #define VI vector<int> #define PI pair<int,int> #define SI (a) ((a). Size ()) #define PR (Kcase,ans) printf ("
Case #%d:%i64d\n ", Kcase,ans); #define PRI (A,n) for (i,n-1) cout<<a[i]<< ";
cout<<a[n]<<endl;
                   #define PRI2D (A,n,m) for (i,n) {\     for (j,m-1) cout<<a[i][j]<< "; \ cout<<a[i][m]<<endl; \} #pragma COMMENT (linker, "/stack:102400000,102400000") #define ALL (x) (x). Begin (), (x). End () Ty
Pedef Long Long ll; typedef LONG <

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.