結果

問題 No.554 recurrence formula
ユーザー 9071tomato9071tomato
提出日時 2017-08-11 23:22:18
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,286 bytes
コンパイル時間 1,013 ms
コンパイル使用メモリ 91,268 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-20 23:38:38
合計ジャッジ時間 1,563 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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;
			aOdd.push_back(temp);
			imosuOdd+=temp;
			imosuOdd%=INF;
		}
		else{//index
			temp=i*imosuOdd;
			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