結果

問題 No.320 眠れない夜に
ユーザー 37zigen37zigen
提出日時 2016-05-03 22:19:35
言語 Java21
(openjdk 21)
結果
AC  
実行時間 148 ms / 2,000 ms
コード長 659 bytes
コンパイル時間 2,741 ms
コンパイル使用メモリ 77,404 KB
実行使用メモリ 54,612 KB
最終ジャッジ日時 2024-04-15 11:04:35
合計ジャッジ時間 8,427 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 141 ms
54,140 KB
testcase_01 AC 141 ms
53,808 KB
testcase_02 AC 141 ms
54,256 KB
testcase_03 AC 141 ms
53,892 KB
testcase_04 AC 140 ms
54,136 KB
testcase_05 AC 137 ms
53,812 KB
testcase_06 AC 145 ms
54,056 KB
testcase_07 AC 139 ms
54,112 KB
testcase_08 AC 142 ms
54,228 KB
testcase_09 AC 137 ms
53,932 KB
testcase_10 AC 140 ms
54,364 KB
testcase_11 AC 141 ms
54,144 KB
testcase_12 AC 142 ms
54,312 KB
testcase_13 AC 139 ms
53,824 KB
testcase_14 AC 139 ms
54,372 KB
testcase_15 AC 137 ms
53,932 KB
testcase_16 AC 140 ms
54,212 KB
testcase_17 AC 140 ms
53,996 KB
testcase_18 AC 142 ms
54,612 KB
testcase_19 AC 146 ms
54,400 KB
testcase_20 AC 144 ms
54,192 KB
testcase_21 AC 143 ms
54,176 KB
testcase_22 AC 148 ms
54,192 KB
testcase_23 AC 142 ms
54,308 KB
testcase_24 AC 141 ms
54,204 KB
testcase_25 AC 142 ms
53,988 KB
testcase_26 AC 143 ms
54,212 KB
testcase_27 AC 147 ms
54,144 KB
testcase_28 AC 139 ms
54,068 KB
testcase_29 AC 143 ms
54,092 KB
testcase_30 AC 142 ms
54,352 KB
testcase_31 AC 146 ms
53,872 KB
testcase_32 AC 145 ms
54,136 KB
testcase_33 AC 143 ms
54,092 KB
testcase_34 AC 140 ms
53,828 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukicoder;
import java.util.Arrays;
import java.util.Scanner;
public class Main{
	public static void main(String[] args)throws Exception{
		new Main().solve();
	}
	long[] fibo;
	void solve(){
		Scanner sc=new Scanner(System.in);
		fibo=new long[81];fibo[1]=1;fibo[2]=1;
		for(int i=3;i<=80;i++)fibo[i]=fibo[i-1]+fibo[i-2];
		int n=sc.nextInt();
		long m=sc.nextLong();
		m=fibo[n]-m;
		int count=0;
		for(long i=n-2;i>=1;i--){
			if(fibo[(int)i]<=m){
				m-=fibo[(int)i];
				count++;
			}
			if(m==0)break;
		}
		if(m!=0)System.out.println(-1);
		else System.out.println(count);
	}
	void tr(Object...o){System.out.println(Arrays.deepToString(o));}
}
0