結果

問題 No.554 recurrence formula
ユーザー hamrayhamray
提出日時 2017-11-23 23:00:16
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 526 bytes
コンパイル時間 1,067 ms
コンパイル使用メモリ 143,064 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-18 03:31:05
合計ジャッジ時間 5,047 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

int odd(int n){
    int temp = 0;
    if(n == 1) return 1;
    for(int i = n-1; i >=1; i -= 2){
        temp += odd(i);
    } 
    return temp * n;
}
int even(int n){
    int temp = 0;
    if(n == 2) return n * 1;
    for(int i = n-1; i>=1; i -= 2){
        temp += even(i);
    }
    return temp * n;
}
int main(){  
    int n; cin >> n;
    int ans = 0;
    if(n % 2 == 0){
        ans += odd(n);
    }else{
        ans += even(n);
    }
    cout << ans << endl;
    return 0;
}
0