結果

問題 No.194 フィボナッチ数列の理解(1)
ユーザー sugarrr
提出日時 2018-03-10 12:17:48
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 1,152 bytes
コンパイル時間 601 ms
コンパイル使用メモリ 79,268 KB
実行使用メモリ 11,392 KB
最終ジャッジ日時 2024-10-13 06:06:23
合計ジャッジ時間 1,735 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other AC * 10 WA * 27
権限があれば一括ダウンロードができます

ソースコード

diff #


#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<bitset>

using namespace std;
typedef long long ll;
#define i_7 1000000007
#define i_5 1000000005

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
#define inf 100000000/*10^8*/
/*#define rep(i,l,r) for(int i=l;i<=r;i++)*/
const double EPS=1E-8;

////////////////////////////////////////

#define rep(i,l,r) for(ll i=l;i<=r;i++)
int main() {
    ll n,k;cin>>n>>k;
    ll a[n];rep(i,0,n-1)cin>>a[i];
    if(k<=1000000){
        ll b[k];
        ll all=0,sum=0;
        rep(i,0,n-1){
            b[i]=a[i];
            all=mod(all+b[i]);
            sum=mod(sum+b[i]);
            /*cout<<all<<" "<<sum<<endl;*/
        }
        rep(i,n,k-1){
            b[i]=sum;
            sum=mod(sum+b[i]-b[i-n]);
            all=mod(all+b[i]);
            /*cout<<all<<" "<<sum<<endl;*/
        }
        cout<<b[k-1]<<" "<<all<<endl;
    }
    
    
    return 0;
}
0