結果
| 問題 | No.194 フィボナッチ数列の理解(1) |
| コンテスト | |
| ユーザー |
latte0119
|
| 提出日時 | 2015-04-26 23:15:45 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 435 bytes |
| 記録 | |
| コンパイル時間 | 1,199 ms |
| コンパイル使用メモリ | 157,528 KB |
| 実行使用メモリ | 7,552 KB |
| 最終ジャッジ日時 | 2024-07-05 01:27:14 |
| 合計ジャッジ時間 | 6,359 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / 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[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;
}
latte0119