結果
問題 | No.194 フィボナッチ数列の理解(1) |
ユーザー |
![]() |
提出日時 | 2015-04-26 23:24:43 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 435 bytes |
コンパイル時間 | 1,234 ms |
コンパイル使用メモリ | 158,736 KB |
実行使用メモリ | 7,632 KB |
最終ジャッジ日時 | 2024-07-05 02:18:07 |
合計ジャッジ時間 | 6,179 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 RE * 1 |
other | AC * 10 RE * 27 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:9:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 9 | scanf("%d%d",&N,&K); | ~~~~~^~~~~~~~~~~~~~ main.cpp:10:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 10 | for(int i=0;i<N;i++)scanf("%d",&dp[i]); | ~~~~~^~~~~~~~~~~~~
ソースコード
#include<bits/stdc++.h>using namespace std;const int mod=1e9+7;int dp[1000010];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;}