結果

問題 No.194 フィボナッチ数列の理解(1)
コンテスト
ユーザー latte0119
提出日時 2015-04-26 23:15:45
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
RE  
実行時間 -
コード長 435 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,081 ms
コンパイル使用メモリ 174,388 KB
実行使用メモリ 7,936 KB
最終ジャッジ日時 2026-03-26 08:07:25
合計ジャッジ時間 7,680 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 RE * 1
other AC * 10 RE * 27
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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

const int mod=1e9+7;
int dp[1000001];
int N,K;

int main(){
    scanf("%d%d",&N,&K);
    for(int i=0;i<N;i++)scanf("%d",&dp[i]);
    int latte=accumulate(dp,dp+N,0ll)%mod;
    for(int i=N;i<K;i++){
        dp[i]=latte;
        latte=(latte-dp[i-N]+mod)%mod;
        latte=(latte+dp[i])%mod;
    }
    latte=accumulate(dp,dp+K,0ll)%mod;
    printf("%d %d\n",dp[K-1],latte);
    return 0;
}
0