其他分享
首页 > 其他分享> > 石油大学----手速赛第三场补题(三)

石油大学----手速赛第三场补题(三)

作者:互联网

明若清溪天下绝歌 缱绻成说,不知该在哪处着墨;一生情深怎奈何世事 徒留斑驳,只一念痴恋成奢。

目录

 

                                             Anton and Polyhedrons

                                                           Cheap Travel

                              The New Year: Meeting Friends

                                                             Double Cola

                                              Ilya and Bank Account


                                             Anton and Polyhedrons

 

Anton's favourite geometric figures are regular polyhedrons. Note that there are five kinds of regular polyhedrons:

All five kinds of polyhedrons are shown on the picture below:

Anton has a collection of n polyhedrons. One day he decided to know, how many faces his polyhedrons have in total. Help Anton and find this number!

Input

The first line of the input contains a single integer n (1 ≤ n ≤ 200 000) — the number of polyhedrons in Anton's collection.

Each of the following n lines of the input contains a string si — the name of the i-th polyhedron in Anton's collection. The string can look like this:

Output

Output one number — the total number of faces in all the polyhedrons in Anton's collection.

Examples

input

Copy

4
Icosahedron
Cube
Tetrahedron
Dodecahedron

output

Copy

42

input

Copy

3
Dodecahedron
Octahedron
Octahedron

output

Copy

28

Note

In the first sample Anton has one icosahedron, one cube, one tetrahedron and one dodecahedron. Icosahedron has 20 faces, cube has 6 faces, tetrahedron has 4 faces and dodecahedron has 12 faces. In total, they have 20 + 6 + 4 + 12 = 42 faces.

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <ctime>
#include <cctype>
#include <bitset>
#include <utility>
#include <sstream>
#include <complex>
#include <iomanip>
#define inf 0x3f3f3f3f
typedef long long ll;
using namespace std;
int jg,n;
string s;
int main(){
    cin>>n;
    getchar();
    while(n--){
        cin>>s;
        if(s=="Tetrahedron")
            jg+=4;
        else if(s=="Cube")
            jg+=6;
        else if(s=="Octahedron")
            jg+=8;
        else if(s=="Dodecahedron")
            jg+=12;
        else if(s=="Icosahedron")
            jg+=20;
    }
    cout<<jg<<endl;
    return 0;
}

                                                           Cheap Travel

Ann has recently started commuting by subway. We know that a one ride subway ticket costs a rubles. Besides, Ann found out that she can buy a special ticket for m rides (she can buy it several times). It costs b rubles. Ann did the math; she will need to use subway n times. Help Ann, tell her what is the minimum sum of money she will have to spend to make n rides?

Input

The single line contains four space-separated integers nmab (1 ≤ n, m, a, b ≤ 1000) — the number of rides Ann has planned, the number of rides covered by the m ride ticket, the price of a one ride ticket and the price of an m ride ticket.

Output

Print a single integer — the minimum sum in rubles that Ann will need to spend.

Examples

input

Copy

6 2 1 2

output

Copy

6

input

Copy

5 2 2 3

output

Copy

8

Note

In the first sample one of the optimal solutions is: each time buy a one ride ticket. There are other optimal solutions. For example, buy three m ride tickets.

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <ctime>
#include <cctype>
#include <bitset>
#include <utility>
#include <sstream>
#include <complex>
#include <iomanip>
#define inf 0x3f3f3f3f
typedef long long ll;
using namespace std;
int m,n,a,b;
int main()
{
    cin>>n>>m>>a>>b;
    int jg=inf;
    for(int i=0; i<=1000; i++)
        for(int j=0; j<=1000; j++)
            if(i+j*m>=n)
                jg=min(jg,a*i+b*j);
    cout<<jg<<endl;
    return 0;
}

                              The New Year: Meeting Friends

There are three friend living on the straight line Ox in Lineland. The first friend lives at the point x1, the second friend lives at the point x2, and the third friend lives at the point x3. They plan to celebrate the New Year together, so they need to meet at one point. What is the minimum total distance they have to travel in order to meet at some point and celebrate the New Year?

It's guaranteed that the optimal answer is always integer.

Input

The first line of the input contains three distinct integers x1, x2 and x3 (1 ≤ x1, x2, x3 ≤ 100) — the coordinates of the houses of the first, the second and the third friends respectively.

Output

Print one integer — the minimum total distance the friends need to travel in order to meet together.

Examples

input

Copy

7 1 4

output

Copy

6

input

Copy

30 20 10

output

Copy

20

Note

In the first sample, friends should meet at the point 4. Thus, the first friend has to travel the distance of 3 (from the point 7 to the point 4), the second friend also has to travel the distance of 3 (from the point 1 to the point 4), while the third friend should not go anywhere because he lives at the point 4.

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <ctime>
#include <cctype>
#include <bitset>
#include <utility>
#include <sstream>
#include <complex>
#include <iomanip>
#define inf 0x3f3f3f3f
typedef long long ll;
using namespace std;
int x[5];
int main(){
    cin>>x[0]>>x[1]>>x[2];
    sort(x,x+3);
    cout<<x[2]-x[0]<<endl;
    return 0;
}

                                                             Double Cola

Sheldon, Leonard, Penny, Rajesh and Howard are in the queue for a "Double Cola" drink vending machine; there are no other people in the queue. The first one in the queue (Sheldon) buys a can, drinks it and doubles! The resulting two Sheldons go to the end of the queue. Then the next in the queue (Leonard) buys a can, drinks it and gets to the end of the queue as two Leonards, and so on. This process continues ad infinitum.

For example, Penny drinks the third can of cola and the queue will look like this: Rajesh, Howard, Sheldon, Sheldon, Leonard, Leonard, Penny, Penny.

Write a program that will print the name of a man who will drink the n-th can.

Note that in the very beginning the queue looks like that: Sheldon, Leonard, Penny, Rajesh, Howard. The first person is Sheldon.

Input

The input data consist of a single integer n (1 ≤ n ≤ 109).

It is guaranteed that the pretests check the spelling of all the five names, that is, that they contain all the five possible answers.

Output

Print the single line — the name of the person who drinks the n-th can of cola. The cans are numbered starting from 1. Please note that you should spell the names like this: "Sheldon", "Leonard", "Penny", "Rajesh", "Howard" (without the quotes). In that order precisely the friends are in the queue initially.

Examples

input

Copy

1

output

Copy

Sheldon

input

Copy

6

output

Copy

Sheldon

input

Copy

1802

output

Copy

Penny
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <ctime>
#include <cctype>
#include <bitset>
#include <utility>
#include <sstream>
#include <complex>
#include <iomanip>
#define inf 0x3f3f3f3f
typedef long long ll;
using namespace std;
string S[] = {"Sheldon", "Leonard", "Penny", "Rajesh", "Howard"};
int n;
int main(){
	cin>>n;
	int i = 1;
	while (n > i*5)
	{
		n -= i*5;
		i <<= 1;
	}
	int ct = n / i;
	if (n % i)
        ct++;
	cout<<S[ct-1];
    return 0;
}

                                              Ilya and Bank Account

Ilya is a very clever lion, he lives in an unusual city ZooVille. In this city all the animals have their rights and obligations. Moreover, they even have their own bank accounts. The state of a bank account is an integer. The state of a bank account can be a negative number. This means that the owner of the account owes the bank money.

Ilya the Lion has recently had a birthday, so he got a lot of gifts. One of them (the gift of the main ZooVille bank) is the opportunity to delete the last digit or the digit before last from the state of his bank account no more than once. For example, if the state of Ilya's bank account is -123, then Ilya can delete the last digit and get his account balance equal to -12, also he can remove its digit before last and get the account balance equal to -13. Of course, Ilya is permitted not to use the opportunity to delete a digit from the balance.

Ilya is not very good at math, and that's why he asks you to help him maximize his bank account. Find the maximum state of the bank account that can be obtained using the bank's gift.

Input

The single line contains integer n (10 ≤ |n| ≤ 109) — the state of Ilya's bank account.

Output

In a single line print an integer — the maximum state of the bank account that Ilya can get.

Examples

input

Copy

2230

output

Copy

2230

input

Copy

-10

output

Copy

0

input

Copy

-100003

output

Copy

-10000

Note

In the first test sample Ilya doesn't profit from using the present.

In the second test sample you can delete digit 1 and get the state of the account equal to 0。

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <ctime>
#include <cctype>
#include <bitset>
#include <utility>
#include <sstream>
#include <complex>
#include <iomanip>
#define inf 0x3f3f3f3f
typedef long long ll;
using namespace std;
int main(){
    int n,jg;
    cin>>n;
    if(n>=0)
        cout<<n<<endl;
    else{
        n=-n;
        jg=min((n/100)*10+n%10,n/10);
        if(jg==0)
            cout<<jg<<endl;
        else
            cout<<'-'<<jg<<endl;
    }
    return 0;
}

 

标签:手速赛,Copy,int,Anton,补题,input,include,bank,第三场
来源: https://blog.csdn.net/weixin_44170305/article/details/100802621