Logo
(追記) (追記ここまで)

33539번 - Debug 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 2048 MB45383183.784%

문제

You just joined a new team to participate in the FPC, because the previous member left the team frustrated. Frustrated that he could not beat a time limit1 of a certain problem of an earlier FPC. To show you indeed posses the skills to solve problems during a FPC, you decide to solve the problem the other member could not. Unfortunately, he never told anyone which problem he was actually trying to solve. Luckily, you still got his code!

Your task is to debug the problem his code is solving and speed it up. You may assume that in its current state, it is correct but too slow. The (Java) code is given below.

import java.util.Scanner;
class D {
 public static int n(int n) {
 int p = 1;
 if (n == 1 || n == 0) p = 0;
 for (int i = 1; i < n; i++) {
 if (i == 1) continue;
 if (n % i == 0) p = 0;
 }
 return p;
 }
 public static void main(String[] args) {
 Scanner sc = new Scanner(System.in);
 if (n(sc.nextInt()) == 1) System.out.println("yes");
 else System.out.println("no");
 }
}

1This was based on the text "Correct but TIME LIMIT! AARGH!" being scratched in the wall.

입력

As can be seen in the provided code. The only input is an integer 0ドル \leq n \leq 10^9$.

출력

Keep the same output as provided in the code. You only need to speed up things.

제한

예제

None! Run the code and try to figure out what is implemented.

힌트

출처

University > Delft University of Technology > Freshmen Programming Contest 2016 D번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /