您的位置:首页 > 其它

Practice Round China New Grad Test 2014

2013-09-15 14:48 162 查看

1 Problem -Bad Horse

As the leader of the Evil League of Evil, Bad Horse has a lot of problems to deal with. Most recently, there have been far too many arguments and far too much backstabbing in the League, so much so that Bad Horse has decided to split the league into two
departments in order to separate troublesome members. Being the Thoroughbred of Sin, Bad Horse isn't about to spend his valuable time figuring out how to split the League members by himself. That what he's got you -- his loyal henchman -- for.

Input

The first line of the input gives the number of test cases, TT test cases follow.  Each test case starts with a positive integerM on a line by itself -- the number of troublesome pairs of League members.
The nextM lines each contain a pair of names, separated by a single space.

Output

For each test case, output one line containing "Case #x: y", where x is the case number (starting from 1) and y is either "Yes" or "No", depending on whether the League members mentioned in the input can be split into two groups with neither of the groups
containing a troublesome pair.

Limits

1 ≤ T ≤ 100.

Each member name will consist of only letters and the underscore character.

Names are case-sensitive.

No pair will appear more than once in the same test case.

Each pair will contain two distinct League members.

Small dataset

1 ≤ M ≤ 10.

Large dataset

1 ≤ M ≤ 100.

Sample

Input

 
Output

 
2

1

Dead_Bowie Fake_Thomas_Jefferson

3

Dead_Bowie Fake_Thomas_Jefferson

Fake_Thomas_Jefferson Fury_Leika

Fury_Leika Dead_Bowie
Case #1: Yes

Case #2: No
 

2  Problem-Captain Hammer

The Hamjet is a true marvel of aircraft engineering. It is a jet airplane with a single engine so powerful that it burns all of its fuel instantly during takeoff. The Hamjet doesn't have any wings because who needs them when the fuselage is made of a special
Wonderflonium isotope that makes it impervious to harm.

Piloting the Hamjet is a not a job for your typical, meek-bodied superhero. That's why the Hamjet belongs to Captain Hammer, who is himself impervious to harm. The G-forces that the pilot endures when taking a trip in the Hamjet are legen-dary.

The Hamjet takes off at an angle of θ degrees up and a speed of V meters per second.V is a fixed value that is determined by the awesome power of the Hamjet engine and the capacity of its fuel tank. The destination isD
meters away. Your job is to program the Hamjet's computer to calculate θ givenV andD.

Fortunately, the Hamjet's Wondeflonium hull is impervious to air friction. Even more fortunately, the Hamjet doesn't fly too far or too high, so you can assume that the Earth is flat, and that the acceleration due to gravity is a constant 9.8m/s2
down.

Input

The first line of the input gives the number of test cases, TT lines follow.  Each line will contain two positive integers --V andD.

Output

For each test case, output one line containing "Case #x: θ", where x is the case number (starting from 1) and θ is in degrees up from the the horizontal. If there are several possible answers, output the smallest positive one.

An answer will be considered correct if it is within 10-6 of the exact answer, in absolute or relative error. See theFAQ
for an explanation of what that means, and what formats of floating-point numbers we accept.

Limits

1 ≤ T ≤ 4500;

1 ≤ V ≤ 300;

1 ≤ D ≤ 10000;

It is guaranteed that each test case will be solvable.

Sample

Input

 
Output

 
3

98 980

98 490

299 1234
Case #1: 45.0000000

Case #2: 15.0000000

Case #3: 3.8870928
设角度为a

 根据物理公式可得 Vsina/g=1/2*(D/vcosa), 可得 sin(2a)=D*g/(V^2), 故角度 a=arcsin(D*g/(V^2))/2;

#include<iostream>
#include<string>
#include<math.h>
using namespace std;
//Problem B. Captain Hammer
void main(){
double g=9.8;
//	double PI=3.14159265358979323846264338327950288419716939937510;
double PI=acos(-1);
int t;
int k=1;
double v,d;
freopen("C:\\Users\\Administrator\\Desktop\\B-small-practice.in","r",stdin);
freopen("C:\\Users\\Administrator\\Desktop\\anwser.txt","w",stdout);
cin>>t;
//printf("%.52f\n",PI);
while(k<=t){
cin>>v>>d;
//double res= (int(d*g/(v*v)*1000000+0.50))*0.0000010f;
double res=d*g/(v*v);
if(fabs(res-1.000000)<1.0e-6){
res=1.000000;
}
printf("Case #%d: %.7f\n",k,asin(res)*180/(PI*2));
k++;
}

}


3 Problem-Moist

Moist has a hobby -- collecting figure skating trading cards. His card collection has been growing, and it is now too large to keep in one disorganized pile. Moist needs to sort the cards in alphabetical order, so that he can find the cards that he wants
on short notice whenever it is necessary.

The problem is -- Moist can't actually pick up the cards because they keep sliding out his hands, and the sweat causes permanent damage. Some of the cards are rather expensive, mind you. To facilitate the sorting, Moist has convinced Dr. Horrible to build
him a sorting robot. However, in his rather horrible style, Dr. Horrible has decided to make the sorting robot charge Moist a fee of $1 whenever it has to move a trading card during the sorting process.

Moist has figured out that the robot's sorting mechanism is very primitive. It scans the deck of cards from top to bottom. Whenever it finds a card that is lexicographically smaller than the previous card, it moves that card to its correct place in the stack
above. This operation costs $1, and the robot resumes scanning down towards the bottom of the deck, moving cards one by one until the entire deck is sorted in lexicographical order from top to bottom.

As wet luck would have it, Moist is almost broke, but keeping his trading cards in order is the only remaining joy in his miserable life. He needs to know how much it would cost him to use the robot to sort his deck of cards.

Input

The first line of the input gives the number of test cases, TT test cases follow.  Each one starts with a line containing a single integer,N. The nextN lines each contain the name of a
figure skater, in order from the top of the deck to the bottom.

Output

For each test case, output one line containing "Case #x: y", where x is the case number (starting from 1) and y is the number of dollars it would cost Moist to use the robot to sort his deck of trading cards.

Limits

1 ≤ T ≤ 100.

Each name will consist of only letters and the space character.

Each name will contain at most 100 characters.

No name with start or end with a space.

No name will appear more than once in the same test case.

Lexicographically, the space character comes first, then come the upper case letters, then the lower case letters.

Small dataset

1 ≤ N ≤ 10.

Large dataset

1 ≤ N ≤ 100.

Sample

Input

 
Output

 
2

2

Oksana Baiul

Michelle Kwan

3

Elvis Stojko

Evgeni Plushenko

Kristi Yamaguchi
Case #1: 1

Case #2: 0
 

这道题实际上属于插入排序的范畴,但是并未计算插入排序的总共移动次数,而是计算有多少个数字不是有序的。

在实际编码中,只需保留以前序列中当前最大值即可,

如果后一个数小于当前最大值,则此数不是有序的,需要插入到前面的有序中,花费代价+1,

否则 保存此数为当前最大值

int main(){
freopen("C:\\Users\\Administrator\\Desktop\\C-small-practice-2.in","r",stdin);
freopen("C:\\Users\\Administrator\\Desktop\\anwser.txt","w",stdout);
int cases;
int k=1;
int n;
char max_str[101];
char tmp[101];
int count=0;
scanf("%d",&cases);
while(k<=cases){
scanf("%d\n",&n);// 注意后面加'\n',否则会影响gets函数
//getchar();
count=0;
gets(max_str);//每次保留最大的数即可
for(int i=1;i<n;i++){
gets(tmp);
if(strcmp(tmp,max_str)<0){
count++;
}
else
strcpy(max_str,tmp);

}
printf("Case #%d: %d\n",k,count);

k++;
}
return 0;
}


 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: