BOJ 1011 Fly me to the Alpha Centauri

1 개요[ | ]

BOJ 1011 Fly me to the Alpha Centauri
  • 거리에 따른 장치 사용 횟수를 출력하는 문제

2 Java[ | ]

import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
	    int c = sc.nextInt();
		for (int i=0; i<c; i++) {
		    int a = sc.nextInt();
		    int b = sc.nextInt();
		    int d = b - a;
		    int move = (int) (Math.sqrt(d-0.5)*2.0);
		    System.out.println( move );
		}
	}
}

3 Perl[ | ]

$n=<>;
for (1..$n) {
    ($m, $o) = (split / +/, <>);
    $d = $o - $m;
    $move = int (sqrt($d-0.5)*2.0);
    printf("%d\n", $move);
}

4 PHP[ | ]

<?php
$n = intval(fgets(STDIN));
for($i=0; $i<$n; $i++) {
    fscanf(STDIN, '%d %d', $x, $y);
    echo intval(sqrt($y-$x-0.5)*2) ."\n";
}

5 Python[ | ]

import math
TT = int(input())
for t in range(TT):
    a, b = map(int,input().split())
    print( int((b-a-.5)**.5*2) )
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}