Skip to content

Instantly share code, notes, and snippets.

@mizushou
Created October 8, 2017 17:32
Show Gist options
  • Save mizushou/29847230b49bc8219be8919931e9f3a6 to your computer and use it in GitHub Desktop.
Save mizushou/29847230b49bc8219be8919931e9f3a6 to your computer and use it in GitHub Desktop.
CODE FESTIVAL 2017 qual B 問題A
import java.util.Scanner;
class Xxfestival {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
String str = scan.next();
int l =str.length();
System.out.println(str.substring(0, l-8));
}
}
@mizushou
Copy link
Author

mizushou commented Oct 8, 2017

  • Stringクラスのsubstringメソッドを使用
  • 文字の後ろ8文字を除いた文字列を取得

問題文

りんごさんは、とある祭りに参加しようとしています。

その祭りの名称が FESTIVAL で終わる文字列 S として入力に与えられるので、りんごさんが何の祭りに参加しようしているのかを出力して下さい。

ただし、s の祭りの名称は s の末尾に FESTIVAL を 1 つだけ追加した文字列であるとします。 例えば CODEFESTIVAL は CODE の祭りです。

制約

9≤|S|≤50
S は大文字アルファベットのみからなる
S は FESTIVAL で終わる

@mizushou
Copy link
Author

mizushou commented Oct 8, 2017

  • substringのindexも配列同様、0~n
  • 注意点はendのindexの直前の位置までの部分文字列となる
    • abcdefで0-2を指定したらabcではなくabになる

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment