結果

問題 No.554 recurrence formula
ユーザー fjafjafjafjafjafja
提出日時 2017-08-22 23:54:33
言語 Java21
(openjdk 21)
結果
AC  
実行時間 134 ms / 2,000 ms
コード長 545 bytes
コンパイル時間 3,212 ms
コンパイル使用メモリ 74,312 KB
実行使用メモリ 54,404 KB
最終ジャッジ日時 2024-04-23 04:50:35
合計ジャッジ時間 6,762 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
53,824 KB
testcase_01 AC 109 ms
52,764 KB
testcase_02 AC 116 ms
53,900 KB
testcase_03 AC 118 ms
54,180 KB
testcase_04 AC 129 ms
54,068 KB
testcase_05 AC 126 ms
54,404 KB
testcase_06 AC 127 ms
54,100 KB
testcase_07 AC 103 ms
52,824 KB
testcase_08 AC 118 ms
53,960 KB
testcase_09 AC 125 ms
54,036 KB
testcase_10 AC 118 ms
54,364 KB
testcase_11 AC 119 ms
53,968 KB
testcase_12 AC 134 ms
54,236 KB
testcase_13 AC 119 ms
53,964 KB
testcase_14 AC 117 ms
54,352 KB
testcase_15 AC 119 ms
53,868 KB
testcase_16 AC 125 ms
54,332 KB
testcase_17 AC 117 ms
53,080 KB
testcase_18 AC 106 ms
53,048 KB
testcase_19 AC 129 ms
54,248 KB
testcase_20 AC 131 ms
54,240 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukicoder;

import java.util.Scanner;

public class N554
{
	public static void main(String[] args)
	{
		long e=0;//evennumber
		long o=1;//oddnumber
		int p=1;
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		long ans=0;
		if(n==1)
		{
			ans=1;
		}
		else
		{
			do
			{
				ans=0;
				p++;
				if(p%2==0)
				{
					ans=p*o%((long)Math.pow(10, 9)+7);
					e+=ans;
				}
				else
				{
					ans=p*e%((long)Math.pow(10, 9)+7);
					o+=ans;
				}
			}while(p!=n);
		}
		System.out.println(ans%((long)Math.pow(10, 9)+7));
	}
}
0