Posts

Showing posts from March, 2016

【筆記】【機器學習】Supervised learning 與 Unsupervised learning

Image
課程連結 Supervised Learning (監督學習) 可以由訓練資料中學到或建立一個模式(函數 / learning model),並依此模式推測新的實例。---Wiki 所以簡單來說就是可以預測和得知確實的輸出而且需要有明確的輸入來告訴計算機要做甚麼  例如從房價預測中可以預測到該平方米的房子需要多少錢  從癌症診斷中可以判斷出是否有癌症  再例如  我現在要從一堆硬幣中找出十元    所以這裡十元的特徵是: 圓形 所有圓形中最大 所以就可以知道最右邊的是十元了 Unsupervised Learning(無監督學習) 並不需要人力來輸入標籤—wiki 與監督學習不同的是無監督學習不需要明確的輸入  再以這圖為例    無監督學習可以幫我們將這三枚硬幣分類,然而它卻不能告訴我們這堆硬幣中那個是十元  注意它不是一個分類系統  它會將特徵相同的聚集在一起  稱為「聚類」

【UVa】11804 - Argentina

Problem  here Problem The Argentine football team coach, the great Diego Maradona,  is going to try out a new formation this year. Formation describes  how the players are positioned on the pitch. Instead of  the conventional 4-4-2 or 4-3-3, he has opted for 5-5. This means  there are 5 attackers and 5 defenders.  You have been hired by Argentina Football Federation (AFF)  to write a code that will help them figure out which players should  take the attacking/defensive positions.  Maradona has given you a list containing the names of the  10 players who will take the field. The attacking ability and the  defensive ability of each player are also given. Your job is to  figure out which 5 players should take the attacking positions  and which 5 should take the defensive positions.  The rules that need to be followed to make the decision are:  • The sum of the attacking abilities of the 5 attackers needs to be ...

【UVa】441 - Lotto

Problem In the German Lotto you have to select 6 numbers from the set {1,2,…,49}. A popular strategy to play Lotto - although it doesn’t increase your chance of winning - is to select a subset S containing k (k>6) of these 49 numbers, and then play several games with choosing numbers only from S. For example, for k=8 and S = 1,2,3,5,8,13,21,34 there are 28 possible games: [1,2,3,5,8,13], [1,2,3,5,8,21], [1,2,3,5,8,34], [1,2,3,5,13,21], …, [3,5,8,13,21,34]. Your job is to write a program that reads in the number k and the set S and then prints all possible games choosing numbers only from S. Input Specification The input file will contain one or more test cases. Each test case consists of one line containing several integers separated from each other by spaces. The first integer on the line will be the number k (6 < k < 13). Then k integers, specifying the set S, will follow in ascending order. Input will be terminated by a value of zero (0) for k. Output Spe...

【UVa】10360 - Rat Attack

Problem  here Problem Baaaam! Another deadly gas bomb explodes in Manhattan’s underworld. Rats have taken over the sewerage and the city council is doing everything to get the rat population under control. As you know, Manhattan is organized in a regular fashion with streets and avenues arranged like a rectangular grid. Waste water drains run beneath the streets in the same arrangement and the rats have always set up their nests below street intersections. The only viable method to extinguish them is to use gas bombs like the one which has just exploded. However, gas bombs are not only dangerous for rats. The skyscrapers above the explosion point have to be evacuated in advance and so the point of rat attack must be chosen very carefully. The gas bombs used are built by a company called American Catastrophe Management (ACM) and they are sold under the heading of “smart rat gas”. They are smart because —when fired— the gas spreads in a rectangular fashion through the ...

【CodeForces】A. Dragons

Problem  here Problem Kirito is stuck on a level of the MMORPG he is playing now. To move on in the game, he’s got to defeat all n dragons that live on this level. Kirito and the dragons have strength, which is represented by an integer. In the duel between two opponents the duel’s outcome is determined by their strength. Initially, Kirito’s strength equals s. If Kirito starts duelling with the i-th (1 ≤ i ≤ n) dragon and Kirito’s strength is not greater than the dragon’s strength xi, then Kirito loses the duel and dies. But if Kirito’s strength is greater than the dragon’s strength, then he defeats the dragon and gets a bonus strength increase by yi. Kirito can fight the dragons in any order. Determine whether he can move on to the next level of the game, that is, defeat all dragons without a single loss. Input The first line contains two space-separated integers s and n (1 ≤ s ≤ 104, 1 ≤ n ≤ 103). Then n lines follow: the i-th line contains space-separated integers x...

【CodeForces】A. Football

Problem  here Problem Petya loves football very much. One day, as he was watching a football match, he was writing the players’ current positions on a piece of paper. To simplify the situation he depicted it as a string consisting of zeroes and ones. A zero corresponds to players of one team; a one corresponds to players of another team. If there are at least 7 players of some team standing one after another, then the situation is considered dangerous. For example, the situation 00100110111111101 is dangerous and 11110111011101 is not. You are given the current situation. Determine whether it is dangerous or not. Input The first input line contains a non-empty string consisting of characters “0” and “1”, which represents players. The length of the string does not exceed 100 characters. There’s at least one player from each team present on the field. Output Print “YES” if the situation is dangerous. Otherwise, print “NO”. Examples input 001001 outpu...

【CodeForces】A. I Wanna Be the Guy

Problem  here Problem There is a game called “I Wanna Be the Guy”, consisting of n levels. Little X and his friend Little Y are addicted to the game. Each of them wants to pass the whole game.  Little X can pass only p levels of the game. And Little Y can pass only q levels of the game. You are given the indices of levels Little X can pass and the indices of levels Little Y can pass. Will Little X and Little Y pass the whole game, if they cooperate each other? Input The first line contains a single integer n (1 ≤  n ≤ 100). The next line contains an integer p (0 ≤ p ≤ n) at first, then follows p distinct integers a1, a2, …, ap (1 ≤ ai ≤ n). These integers denote the indices of levels Little X can pass. The next line contains the levels Little Y can pass in the same format. It’s assumed that levels are numbered from 1 to n. Output If they can pass all the levels, print “I become the guy.”. If it’s impossible, print “Oh, my keyboard!” (without the quotes). ...