Eclipse導入時のvimとそのほかもろもろについて
個人的な備忘録として。
Eclipseを導入する際にいつも入れる
Vimとその設定についてのメモ書きです。
▼Eclipseの導入
Pleiades - Eclipse プラグイン日本語化プラグイン
▼JDKの導入
Java SE – Downloads | Oracle Technology Network | Oracle
▼Pathの設定
Program Files\Java\jdk(ry\bin
↑
アドレスをコピーしておく。
コントロールパネル→システム→システム詳細設定→環境変数→システム環境変数→Path
Pathの最後に「;」で区切って、先程コピーしたフォルダのアドレスをペースト。
Android SDK | Android Developers
DOWNLOAD FOR OTHER PLATFORMS→SDK Tools Only→installer_r22.6-windows.exe
Andoid SDK Manager
◎
・Android SDK Tools
・Android SDK Platform-tools
○
・Android SDK Build-tools
・Android 4.4.2(API 19)内の全部
△
・Android Support Library
・Google USB Driver
EclipseからAndroid SDKを使えるようにする設定
Help -> Install New Software add -> Name[Android plugin],Location[http://dl-ssl.google.com/android/eclipse/]
▼com.google.android.gmsを読み込ませる方法
window -> Android SDK Manager -> Extra -> Google Play service -> install
C:\Program Files\adt-bundle-windows-x86_64-20140321\sdk\extras\google\google_play_services\libproject\google-play-services_lib
をEclipseでAndroidプロジェクトとしてインポートする。
Google Play Serviceを利用したいプロジェクトで右クリック→Properties→Android→Library→add
▼Vimの追加
Help -> Install New Software add -> Name[vrapper],Location[http://vrapper.sourceforge.net/update-site/stable/]
とりあえず、select allをしてaccept等して再起動で完了。
VimボタンのタッチでON/OFF切り替え可能
▼導入したVimに機能を追加
・補間候補を最大表示させる
Window -> Preferences -> Java -> Editor -> Content Assist auto activation triggers for Java: [.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_]
を追加する
▼ハイライトの設定
Help -> Install New Software [http://eclipse-color-theme.github.com/update/] Window -> Preferences -> General -> Appearence -> Color Theme
好みのものを選択。
私は「RecognEyes」を使用。
以上
Project Euler 0020
・問題リンクFind the sum of digits in 100!
・コメント
概要
n! means n (n 1) ... 3 2 1 For example, 10! = 10 9 ... 3 2 1 = 3628800, and the sum of the digits in the number 10! is 3 + 6 + 2 + 8 + 8 + 0 + 0 = 27. Find the sum of the digits in the number 100!
100!(100の階乗)は明らかにintやlong型の扱える範囲を超える結果になってしまいます。
なのでBigIntegerを使って階乗計算を行った後、各桁を文字列の部分文字列として取り出してそれをint型にキャストして加算していきました。
今までlong型でも扱い切れないような大きい数を扱ったことがなかったので、
BigIntegerに少し触れる機会ができたのはよかったと思います。
階乗計算も再帰と三項演算子を使うとすっきり書けていいですね。
おしまい。
・ソース
import java.math.BigInteger; public class P0020 { public static void solve(String num) { int ans = 0; int length = num.length(); for (int i = 0; i < length; i++) { ans += Integer.parseInt(num.substring(i, i + 1)); } System.out.println(ans); } public static String factorial(String s) { BigInteger ans = BigInteger.valueOf(1); for (int i = 1; i <= Integer.parseInt(s); i++) { ans = ans.multiply(BigInteger.valueOf(i)); } return ans.toString(); } public static void main(String[] args) { String number = "100"; solve(factorial(number)); } }
AOJ 0101
・問題リンクCircumscribed Circle of a Triangle
・コメント
数学ができなすぎて結局ACできませんでした()
どこかで計算の誤差が生じる演算をしてしまっているのかなと・・。
とりあえず眠いので今日はここまで。
1ヶ月ぶりのコーディングでした。。。
近いうちに解きなおしたいです。。
・ソース
import java.math.BigDecimal; import java.util.Scanner; public class P0010 { static Scanner sc = new Scanner(System.in); public static void solve() { // 入力 double x1 = sc.nextDouble(); double y1 = sc.nextDouble(); double x2 = sc.nextDouble(); double y2 = sc.nextDouble(); double x3 = sc.nextDouble(); double y3 = sc.nextDouble(); calc(x1, y1, x2, y2, x3, y3); } public static void calc(double x1, double y1, double x2, double y2, double x3, double y3) { double xp = ((x1 * x1 + y1 * y1) * (y2 - y3) + (x2 * x2 + y2 * y2) * (y3 - y1) + (x3 * x3 + y3 * y3) * (y1 - y2)) / (x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2)) / 2; double yp = ((x1 * x1 + y1 * y1) * (x2 - x3) + (x2 * x2 + y2 * y2) * (x3 - x1) + (x3 * x3 + y3 * y3) * (x1 - x2)) / (y1 * (x2 - x3) + y2 * (x3 - x1) + y3 * (x1 - x2)) / 2; double r = ((x1 - xp) * (x1 - xp)) + ((y1 - yp) * (y1 - yp)); BigDecimal bi = new BigDecimal(String.valueOf(Math.sqrt(r))); r = bi.setScale(3, BigDecimal.ROUND_HALF_UP).doubleValue(); System.out.printf("%.3f %.3f %.3f", xp, yp, r); } public static void main(String[] args) { int count = sc.nextInt(); while (count > 0) { solve(); count--; } } }
(Open)Tweenの新バージョンに設定をそのまま引き継ぐ(移行する)方法
当方、TwitterをPCで扱う際にはオープンソースの『OpenTween』や『Tween』などを利用させてもらっています。
これらには時折versionのUpdateがあるのですが、
その際に「ユーザー認証」「リストやタブ振り分けで行ったタブの設定」など、
今まで使っていた環境をそのまま新Ver.でも使える為にメモを残しておきます。
といっても簡単な作業です。
・SettingAtIdList.xml ・SettingCommon.xml ・SettingLocal.xml ・SettingTabs.xml
以上、4項目を新しくDLした新Ver.の(Open)Tweenのファイルにコピペするだけで今までの環境を整えられると思います。
当方は『OpenTween』でのみ試して動いているので
『Tween』の方でも大丈夫じゃないかと思います。
はい。以上です。ありがとうございました
Eclipse(EE)でのデフォルトのworkspaceの変更方法
当方、Javaでプログラミングをする際に統合開発環境(IDE)のEclipseを利用させていただいております
前に使っていたデフォルトのworkspaceを使わなくなり、起動する度に使われていないworkspaceからいちいち変更しなければならないのが面倒だったので、ここに変更方法をメモしておきます
変更方法は極めて単純です
例として、デフォルトをoldworkspaceからnewworkspaceに変更する場合、
eclipse(EE)/configuration/config.ini
にある、
osgi.instance.area.default=@user.home/oldworkspace/
を、
osgi.instance.area.default=@user.home/newworkspace/
へと変更するだけです。
これであってると思います。
以上でーす
AOJ 0502
・問題リンクDice
・コメント
問題文をそのまま実装しただけですー
・ソース
import java.util.Scanner; public class P0502 { static int top = 1; static int bottom = 6; static int front = 5; static int back = 2; static int right = 3; static int left = 4; static int temp = 0; public static int north() { temp = front; front = top; top = back; back = bottom; bottom = temp; return top; } public static int south() { temp = top; top = front; front = bottom; bottom = back; back = temp; return top; } public static int east() { temp = top; top = left; left = bottom; bottom = right; right = temp; return top; } public static int west() { temp = left; left = top; top = right; right = bottom; bottom = temp; return top; } public static int right() { temp = back; back = right; right = front; front = left; left = temp; return top; } public static int left() { temp = right; right = back; back = left; left = front; front = temp; return top; } public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (true) { int n = sc.nextInt(); if (n == 0) { break; } top = 1; bottom = 6; front = 5; back = 2; right = 3; left = 4; temp = 0; int sumOfTop = top; for (int i = 0; i < n; i++) { String cmd = sc.next(); if (cmd.equals("North")) { sumOfTop += north(); } else if (cmd.equals("South")) { sumOfTop += south(); } else if (cmd.equals("West")) { sumOfTop += west(); } else if (cmd.equals("East")) { sumOfTop += east(); } else if (cmd.equals("Right")) { sumOfTop += right(); } else { sumOfTop += left(); } } System.out.println(sumOfTop); } } }