<pre>import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.<i>in</i>));
StringTokenizer st = new StringTokenizer(br.readLine());
int h = Integer.<i>parseInt</i>(st.nextToken());
int m = Integer.<i>parseInt</i>(st.nextToken());
int t = Integer.<i>parseInt</i>(br.readLine());
if( 0 <= h && h <= 23 && 0 <= m && m <= 59 && 0 <= t && t <= 1000) {
int totalM = m + t; // 총합타이머
int tH = totalM / 60; // 추가해야할 시간
int tM = totalM % 60; // 나타낼 분
System.<i>out</i>.println("totalM : " + totalM);
System.<i>out</i>.println("tH : " + tH);
System.<i>out</i>.println("tM : " + tM);
int resultT = (h + tH) % 24;
System.<i>out</i>.println(resultT +" " + tM);
}
}
}</pre>
왜 틀린걸까요 ..
돌리면 값은 맞습니다 .
백준에서 틀리다고 나옵니다 .
dong3512 1년 전 1
<pre>import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.<i>in</i>)); StringTokenizer st = new StringTokenizer(br.readLine()); int h = Integer.<i>parseInt</i>(st.nextToken()); int m = Integer.<i>parseInt</i>(st.nextToken()); int t = Integer.<i>parseInt</i>(br.readLine()); if( 0 <= h && h <= 23 && 0 <= m && m <= 59 && 0 <= t && t <= 1000) { int totalM = m + t; // 총합타이머 int tH = totalM / 60; // 추가해야할 시간 int tM = totalM % 60; // 나타낼 분 System.<i>out</i>.println("totalM : " + totalM); System.<i>out</i>.println("tH : " + tH); System.<i>out</i>.println("tM : " + tM); int resultT = (h + tH) % 24; System.<i>out</i>.println(resultT +" " + tM); } } }</pre> 왜 틀린걸까요 .. 돌리면 값은 맞습니다 . 백준에서 틀리다고 나옵니다 .