結果

問題 No.141 魔法少女コバ
ユーザー uwiuwi
提出日時 2015-02-01 23:25:19
言語 Java21
(openjdk 21)
結果
AC  
実行時間 73 ms / 5,000 ms
コード長 3,401 bytes
コンパイル時間 4,069 ms
コンパイル使用メモリ 79,064 KB
実行使用メモリ 51,648 KB
最終ジャッジ日時 2023-09-05 09:35:05
合計ジャッジ時間 11,417 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 64 ms
50,708 KB
testcase_01 AC 60 ms
50,768 KB
testcase_02 AC 60 ms
50,716 KB
testcase_03 AC 59 ms
48,672 KB
testcase_04 AC 60 ms
50,460 KB
testcase_05 AC 61 ms
50,640 KB
testcase_06 AC 63 ms
50,536 KB
testcase_07 AC 62 ms
50,252 KB
testcase_08 AC 60 ms
50,236 KB
testcase_09 AC 60 ms
50,432 KB
testcase_10 AC 62 ms
50,504 KB
testcase_11 AC 63 ms
50,580 KB
testcase_12 AC 62 ms
50,528 KB
testcase_13 AC 63 ms
50,516 KB
testcase_14 AC 62 ms
50,404 KB
testcase_15 AC 61 ms
50,556 KB
testcase_16 AC 61 ms
50,440 KB
testcase_17 AC 61 ms
50,476 KB
testcase_18 AC 60 ms
50,532 KB
testcase_19 AC 61 ms
50,468 KB
testcase_20 AC 61 ms
50,720 KB
testcase_21 AC 62 ms
51,648 KB
testcase_22 AC 60 ms
50,456 KB
testcase_23 AC 61 ms
50,236 KB
testcase_24 AC 68 ms
50,388 KB
testcase_25 AC 62 ms
50,648 KB
testcase_26 AC 61 ms
50,508 KB
testcase_27 AC 63 ms
50,532 KB
testcase_28 AC 62 ms
50,712 KB
testcase_29 AC 64 ms
50,432 KB
testcase_30 AC 65 ms
50,548 KB
testcase_31 AC 64 ms
50,452 KB
testcase_32 AC 65 ms
50,556 KB
testcase_33 AC 73 ms
50,416 KB
testcase_34 AC 66 ms
50,236 KB
testcase_35 AC 65 ms
50,520 KB
testcase_36 AC 67 ms
50,476 KB
testcase_37 AC 69 ms
50,544 KB
testcase_38 AC 68 ms
50,528 KB
testcase_39 AC 67 ms
50,524 KB
testcase_40 AC 66 ms
50,464 KB
testcase_41 AC 66 ms
50,524 KB
testcase_42 AC 66 ms
50,720 KB
testcase_43 AC 66 ms
50,456 KB
testcase_44 AC 65 ms
50,564 KB
testcase_45 AC 64 ms
50,468 KB
testcase_46 AC 65 ms
50,532 KB
testcase_47 AC 67 ms
50,656 KB
testcase_48 AC 68 ms
50,480 KB
testcase_49 AC 67 ms
50,436 KB
testcase_50 AC 66 ms
50,492 KB
testcase_51 AC 65 ms
50,648 KB
testcase_52 AC 67 ms
50,620 KB
testcase_53 AC 62 ms
50,476 KB
testcase_54 AC 60 ms
50,628 KB
testcase_55 AC 60 ms
50,452 KB
testcase_56 AC 61 ms
50,384 KB
testcase_57 AC 60 ms
50,528 KB
testcase_58 AC 61 ms
50,852 KB
testcase_59 AC 64 ms
50,376 KB
testcase_60 AC 61 ms
50,652 KB
testcase_61 AC 60 ms
50,480 KB
testcase_62 AC 60 ms
50,524 KB
testcase_63 AC 61 ms
50,720 KB
testcase_64 AC 60 ms
50,236 KB
testcase_65 AC 61 ms
50,440 KB
testcase_66 AC 61 ms
50,484 KB
testcase_67 AC 61 ms
50,548 KB
testcase_68 AC 61 ms
50,244 KB
testcase_69 AC 59 ms
50,524 KB
testcase_70 AC 61 ms
50,440 KB
testcase_71 AC 63 ms
51,028 KB
testcase_72 AC 61 ms
50,620 KB
testcase_73 AC 61 ms
50,544 KB
testcase_74 AC 61 ms
50,468 KB
testcase_75 AC 62 ms
50,456 KB
testcase_76 AC 64 ms
50,524 KB
testcase_77 AC 60 ms
50,584 KB
testcase_78 AC 61 ms
50,708 KB
testcase_79 AC 60 ms
50,720 KB
testcase_80 AC 61 ms
50,224 KB
testcase_81 AC 61 ms
50,244 KB
testcase_82 AC 59 ms
50,652 KB
testcase-evil-0.txt AC 60 ms
50,240 KB
testcase-evil-1.txt AC 63 ms
50,652 KB
testcase-evil-2.txt AC 63 ms
50,536 KB
testcase-evil-3.txt AC 60 ms
50,776 KB
testcase-evil-4.txt AC 64 ms
50,548 KB
testcase-evil-5.txt AC 61 ms
50,212 KB
testcase-evil-6.txt AC 62 ms
50,232 KB
testcase-evil-7.txt AC 65 ms
50,720 KB
testcase-evil-8.txt AC 65 ms
50,768 KB
testcase-evil-9.txt AC 64 ms
50,540 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;

public class Main {
	static InputStream is;
	static PrintWriter out;
	static String INPUT = "";
	
	static void solve()
	{
		int m = ni(), n = ni();
		long s = 0;
		while(n != 0){
			s += m/n;
			m %= n;
			if(m == 0)break;
			int u = n; n = m; m = u;
			s++;
		}
		out.println(s-1);
	}
	
	public static void main(String[] args) throws Exception
	{
		long S = System.currentTimeMillis();
		is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);
		
		solve();
		out.flush();
		long G = System.currentTimeMillis();
		tr(G-S+"ms");
	}
	
	private static boolean eof()
	{
		if(lenbuf == -1)return true;
		int lptr = ptrbuf;
		while(lptr < lenbuf)if(!isSpaceChar(inbuf[lptr++]))return false;
		
		try {
			is.mark(1000);
			while(true){
				int b = is.read();
				if(b == -1){
					is.reset();
					return true;
				}else if(!isSpaceChar(b)){
					is.reset();
					return false;
				}
			}
		} catch (IOException e) {
			return true;
		}
	}
	
	private static byte[] inbuf = new byte[1024];
	static int lenbuf = 0, ptrbuf = 0;
	
	private static int readByte()
	{
		if(lenbuf == -1)throw new InputMismatchException();
		if(ptrbuf >= lenbuf){
			ptrbuf = 0;
			try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }
			if(lenbuf <= 0)return -1;
		}
		return inbuf[ptrbuf++];
	}
	
	private static boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }
	private static int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }
	
	private static double nd() { return Double.parseDouble(ns()); }
	private static char nc() { return (char)skip(); }
	
	private static String ns()
	{
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while(!(isSpaceChar(b))){ // when nextLine, (isSpaceChar(b) && b != ' ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	
	private static char[] ns(int n)
	{
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while(p < n && !(isSpaceChar(b))){
			buf[p++] = (char)b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}
	
	private static char[][] nm(int n, int m)
	{
		char[][] map = new char[n][];
		for(int i = 0;i < n;i++)map[i] = ns(m);
		return map;
	}
	
	private static int[] na(int n)
	{
		int[] a = new int[n];
		for(int i = 0;i < n;i++)a[i] = ni();
		return a;
	}
	
	private static int ni()
	{
		int num = 0, b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}
		
		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}
	
	private static long nl()
	{
		long num = 0;
		int b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}
		
		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}
	
	private static void tr(Object... o) { if(INPUT.length() != 0)System.out.println(Arrays.deepToString(o)); }
}
0