1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

AtCoder Beginner Contest 017をやった(Java)

Posted at

AtCoder Beginner Contest 017をやった。
C問題解けない。。

##A
一応Double型で宣言して実装

import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        double ans = 0;
        for(int i = 0; i < 3; i++){
            ans += scan.nextDouble() * (scan.nextDouble() / 10);
        }
        System.out.println((int) ans);
    }
}

##B
全部の文字列をリプレイスしてあげて文字数が0と同じになればYESとなる

import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        String str = scan.nextLine();
        str = str.replaceAll("ch", "").replaceAll("o", "").replaceAll("k", "").replaceAll("u", "");
        if(str.length() == 0){
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}

いつかC問題もJavaで解きたいな(n回目)。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?