結果

問題 No.194 フィボナッチ数列の理解(1)
ユーザー sugarrrsugarrr
提出日時 2018-03-10 12:17:48
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,152 bytes
コンパイル時間 637 ms
コンパイル使用メモリ 78,628 KB
実行使用メモリ 11,264 KB
最終ジャッジ日時 2024-04-21 07:21:25
合計ジャッジ時間 1,702 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
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 AC 13 ms
11,136 KB
testcase_21 AC 13 ms
11,264 KB
testcase_22 AC 12 ms
11,136 KB
testcase_23 AC 4 ms
5,376 KB
testcase_24 AC 8 ms
7,040 KB
testcase_25 AC 7 ms
6,912 KB
testcase_26 AC 7 ms
6,784 KB
testcase_27 AC 7 ms
7,680 KB
testcase_28 AC 4 ms
5,376 KB
testcase_29 AC 12 ms
10,496 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
権限があれば一括ダウンロードができます

ソースコード

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