TopCoder

SRM 462 DIV2

Easy::Archery 問題文を読み違えて時間かかりました。何故かradiusを直径のことだと勘違い・・・。 public class Archery { public double expectedPoints(int N, int[] ringPoints) { double[] array = new double[N + 1]; double sum = 0.0; double r = 0.…

SRM460 DIV2

Easy::TheQuestionsAndAnswersDivTwo public class TheQuestionsAndAnswersDivTwo { public int find(string[] questions) { List<string> q = new List<string>(); foreach (String s in questions) { if (q.Contains(s)) { continue; } else { q.Add(s); } } return (int)M</string></string>…

SRM 404 DIV2 Level.2

ぐだぐたになったけどシステムテストパスしたからおk。 public class RevealTriangle { public int getAns(int a, int b) { int ret = 0; for (int i = 0; i < 10; i++) { if (a == (b + i) % 10) { ret = i; break; } } return ret; } public String[] cal…

SRM414 DIV2 Level.1

ちょっと時間かかった。 public class Pair<T, U> { public Pair() { } public Pair(T first, U second) { this.First = first; this.Second = second; } public T First; public U Second; } public class RestaurantManager { public int allocateTables(int[] t</t,>…

SRM397 DIV2 Level.1

適当に解いたらタイムアウト。 一度試したパターンは飛ばすように書き換えたら普通に通った。 public class Pair<T, U> { public Pair() { } public Pair(T first, U second) { this.First = first; this.Second = second; } public T First; public U Second; } p</t,>…

SRM397 DIV2 Level.1

今日も練習。 簡単。 public class BreakingTheCode { public String decodingEncoding(String code, String message) { String ret = ""; bool isDigit = true; for (int i = 0; i < message.Length; i++) { if (message[i] >= 'a' && message[i] <= 'z') {…

SRM 416 DIV2 Level.1

長いな・・・。 もっとスマートに書けるはず。 public class MostCommonLetters { public String listMostCommon(String[] text) { Dictionary<char, int> dic = new Dictionary<char, int>(); foreach (String s in text) { foreach (Char c in s) { if (c != ' ') { if (dic.Cont</char,></char,>…

SRM 451 DIV2 Level.2

問題文を理解するのに時間がかかってしまった。 感覚で英語読んで、読み飛ばしとかしてるからこうなるんだよな・・・。 using System; using System.Collections.Generic; using System.Text; public class BoredPhilosophers { public int[] simulate(Strin…

SRM 451 DIV2 Level.1

簡単。 using System; using System.Collections.Generic; using System.Text; public class ReverseMagicalSource { public int find(int source, int A) { int ans = 0; int tmp = 1; while (ans <= A) { ans += source * tmp; tmp *= 10; } return ans; }…

SRM420 DIV2 Level.2

パッと見てBFSだとわかるし、これぐらいの問題はすぐに解けないとだめだよな・・・。 結構時間かかってしまった。 using System; using System.Collections.Generic; using System.Text; public class Point { public int X; public int Y; public int D; pu…

SRM417 DIV2 Level.1

今日も練習。 Revese(Reverse(x) + Revese(y)) これを解くだけ。 using System; using System.Collections.Generic; using System.Text; public class ReversedSum { int reverse(int a) { int ret = 0; while (true) { ret += a % 10; if (a >= 10) { ret *…

SRM 453.5 DIV2 Level.1

Stringの配列が与えられて、その中で重複ぬかして単語が何個あるか数える問題。 using System; using System.Collections.Generic; using System.Text; public class ToolsBox { public int countTools(String[] need) { int count = 0; Dictionary<String, int> dic = ne</string,>…

SRM391 DIV2 Level.2

文字列が与えられて、その中の文字を一意に置き換えたら同じになる組み合わせが何個あるか求めろという問題。 C#がよくわかってないんで大分適当。システムテストにパスしたからまあいいんだけどさー。 if (list[i].Equals(list[j]))って書き方は駄目なの? …

SRM391 DIV2 Level.1

雪が積もってる区間が与えられて、どんだけの区間が雪で覆われてるのか求めろって問題。 与えられる区間のデータがかぶっていることもあるので、そこを考慮しないといけない。 using System; using System.Collections.Generic; using System.Text; public c…

SRM395 DIV2 Level.1

今日も元気に頭が悪いgray coderの私です。 せめてgreen目指したいよね!ということでこれからも頑張りたいところです。 0,1,4,9で構成される数字のn番目を求めろって問題。 こんなもんですかね? using System; using System.Collections.Generic; using Sy…

解いてみる

SRM 440 DIV2 250 #include <cmath> #include <vector> using namespace std; class IncredibleMachineEasy { public: double gravitationalAcceleration(vector <int> height, int T); }; double IncredibleMachineEasy::gravitationalAcceleration(vector <int> height, int T) { do</int></int></vector></cmath>…