結果

問題 No.44 DPなすごろく
ユーザー vjudge1
提出日時 2024-02-19 22:30:25
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,334 bytes
コンパイル時間 1,968 ms
コンパイル使用メモリ 191,736 KB
最終ジャッジ日時 2025-02-19 17:17:15
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 20
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:50:16: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   50 |         freopen(NAME".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:51:16: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   51 |         freopen(NAME".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

/*
    Author: hoangvu276
    vnoi: https://oj.vnoi.info/user/hoangvu276
    codeforces: https://codeforces.com/profile/Hoangvu276
*/

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

#define ull unsigned long long
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FOD(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,a,b) for(int i=(a);i>=(b);--i)
#define el cout << '\n';
#define all(v) (v).begin(),(v).end()
#define pii pair<int,int>
#define p2i pair<int,pii>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define faster ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//bitmask
#define bitcnt(n) __builtin_popcount(n)
#define mask(i) (1 << (i))
#define bit(n, i) (((n) >> (i)) & 1)
#define set_on(n, i) ((n)  mask(i))
#define set_off(n, i) ((n) & ~mask(i))

const int INF=1e18+9;
const int MOD=1e9+7;
const int MAXN=1e6+5;
const int base=131;
#define HVu 0

int n, dp[55];

void solve(){
    cin >> n;
    dp[0] = dp[1] = 1;
    FOD(i,2,n) dp[i] = dp[i-1] + dp[i-2];
    cout << dp[n];
}

signed main(){
    #define NAME ""
    faster
    if(fopen(NAME".inp", "r")){
        freopen(NAME".inp", "r", stdin);
        freopen(NAME".out", "w", stdout);
    }

    if(HVu){
        int tc; cin >> tc;
        while(tc--){
            solve();
        }
    } else solve();
}

0