結果
| 問題 |
No.1136 Four Points Tour
|
| ユーザー |
|
| 提出日時 | 2020-07-27 01:25:31 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 638 bytes |
| コンパイル時間 | 523 ms |
| コンパイル使用メモリ | 67,720 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-28 19:55:10 |
| 合計ジャッジ時間 | 1,599 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 41 |
コンパイルメッセージ
main.cpp:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
6 | main()
| ^~~~
ソースコード
#include<iostream>
using namespace std;
const long mod=1e9+7;
long N;
long A[4][4],E[4][4],T[4][4];
main()
{
cin>>N;
for(int i=0;i<4;i++)for(int j=0;j<4;j++)
{
A[i][j]=i==j?0:1;
E[i][j]=i==j?1:0;
}
while(N)
{
if(N&1)
{
for(int i=0;i<4;i++)for(int j=0;j<4;j++)T[i][j]=E[i][j],E[i][j]=0;
for(int k=0;k<4;k++)for(int i=0;i<4;i++)for(int j=0;j<4;j++)
{
(E[i][j]+=T[i][k]*A[k][j]%mod)%=mod;
}
}
N>>=1;
for(int i=0;i<4;i++)for(int j=0;j<4;j++)T[i][j]=A[i][j],A[i][j]=0;
for(int k=0;k<4;k++)for(int i=0;i<4;i++)for(int j=0;j<4;j++)
{
(A[i][j]+=T[i][k]*T[k][j]%mod)%=mod;
}
}
cout<<E[0][0]<<endl;
}