結果

問題 No.554 recurrence formula
ユーザー 9071tomato9071tomato
提出日時 2017-08-11 23:24:46
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 1,318 bytes
コンパイル時間 722 ms
コンパイル使用メモリ 91,160 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-20 23:39:17
合計ジャッジ時間 1,350 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 1 ms
5,376 KB
testcase_18 AC 1 ms
5,376 KB
testcase_19 AC 4 ms
5,376 KB
testcase_20 AC 4 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include <list>
#include<stack>
#include<queue>
#include <vector>
#include <set>
#include <map>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string.h>
#include"time.h"
using namespace std;

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define LL long long
#define CLR(a) memset((a),0,sizeof(a))
#define SZ(x) (int((x).size()))
#define dump(x)  cerr << #x << " = " << (x) << endl

//ςꏊ
#define INF 1000000007

//蕶̂Ƃ
vector<LL> aOdd = vector<LL>(); //å
vector<LL> aEven = vector<LL>();//a̋

LL imosuOdd=1; //å̕a
LL imosuEven=0;//a̋̕a
LL temp;

int N;


int main() {
	cin>>N;

	//za
	aOdd.push_back(1);
	FOR(i,2, N + 1) {
		if(i%2){//index
			temp=i*imosuEven;
			temp%=INF;
			aOdd.push_back(temp);
			imosuOdd+=temp;
			imosuOdd%=INF;
		}
		else{//index
			temp=i*imosuOdd;
			temp %= INF;
			aEven.push_back(temp);
			imosuEven+=temp;
			imosuEven%=INF;
		}
	}
	if (N % 2) cout << aOdd.at(N / 2)<<endl;
	else  cout << aEven.at(N / 2-1)<<endl;

	/*
	REP(i, aEven.size())cout << aEven.at(i) << " ";
	cout<<endl;
	REP(i, aOdd.size())cout << aOdd.at(i) << " ";
	cout<<endl;

	cin>>N;
	*/
	return 0;
}
0