結果
問題 | No.658 テトラナッチ数列 Hard |
ユーザー |
![]() |
提出日時 | 2018-03-02 23:53:58 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 159 ms / 2,000 ms |
コード長 | 740 bytes |
コンパイル時間 | 2,087 ms |
コンパイル使用メモリ | 194,204 KB |
最終ジャッジ日時 | 2025-01-05 08:59:32 |
ジャッジサーバーID (参考情報) |
judge4 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 8 |
コンパイルメッセージ
main.cpp:27:1: warning: ISO C++ forbids declaration of ‘main’ with no type [-Wreturn-type] 27 | main(){ | ^~~~ main.cpp: In function ‘int main()’: main.cpp:29:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 29 | scanf("%d",&Q); | ~~~~~^~~~~~~~~ main.cpp:32:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 32 | scanf("%lld",&n); | ~~~~~^~~~~~~~~~~
ソースコード
#include<bits/stdc++.h> using namespace std; int Z[4][4]; void f(int a[4][4]){ int r[4][4]; for(int y=0;y<4;++y){ for(int x=0;x<4;++x){ r[y][x]=0; } } for(int y=0;y<4;++y){ for(int x=0;x<4;++x){ for(int i=0;i<4;++i){ (r[y][x]+=Z[y][i]*a[i][x])%=17; } } } for(int y=0;y<4;++y){ for(int x=0;x<4;++x){ Z[y][x]=r[y][x]; } } } main(){ int Q; scanf("%d",&Q); for(int i=0;i<Q;++i){ long long n; scanf("%lld",&n); --n; for(int y=0;y<4;++y){ for(int x=0;x<4;++x){ Z[y][x]=x==y; } } for(int i=60;i--;){ f(Z); if(n>>i&1){ int a[4][4]; for(int y=0;y<4;++y){ for(int x=0;x<4;++x){ a[y][x]=y==0|y-1==x; } } f(a); } } printf("%d\n",Z[3][0]); } }