SlideShare a Scribd company logo
1 of 4
Download to read offline
Don't Think Seriously!




      Writer: komiya
問題概要
●   数列Aが次のように定義される。
     A[1] = 0
     A[2] = 1
     A[i+2] = A[i+1]^2 + A[i]^2
●   A[n] % Mを求めよ。

●   n < 2^31
●   M = 1999 or 10^9 + 7
部分点解法
●   A[i]は直前2項だけで決まる。
●   直前2項の mod Mでの値の組は、たかだか
    M^2個しかない。
●   鳩ノ巣原理より、M^2回程度回せば必ずルー
    プを検出できる。
●   ループを見つけたら、その周期の長さを利用
    してA[n]での値を求めることができる。
満点解法
●   ローカルで計算して埋め込む。
●   もちろん全部埋め込むのは無理なので、適当
    な箇所の連続する2項を埋め込む。
●   埋め込み用データは、マシンスペックにもよる
    が1~5分程度で用意できる。

More Related Content

What's hot (6)

Matrix Multiplication in Strassen Algorithm
Matrix Multiplication in Strassen AlgorithmMatrix Multiplication in Strassen Algorithm
Matrix Multiplication in Strassen Algorithm
 
情報オリンピック夏合宿発表
情報オリンピック夏合宿発表情報オリンピック夏合宿発表
情報オリンピック夏合宿発表
 
K2PC Div1 E 暗号化
K2PC Div1 E 暗号化K2PC Div1 E 暗号化
K2PC Div1 E 暗号化
 
【材料力学】幾何学的条件を用いた不静定はりの解法 (I-11-2 2020)
【材料力学】幾何学的条件を用いた不静定はりの解法 (I-11-2 2020)【材料力学】幾何学的条件を用いた不静定はりの解法 (I-11-2 2020)
【材料力学】幾何学的条件を用いた不静定はりの解法 (I-11-2 2020)
 
RUPC2014_Day2_I
RUPC2014_Day2_IRUPC2014_Day2_I
RUPC2014_Day2_I
 
Pyramid
PyramidPyramid
Pyramid
 

Viewers also liked (18)

Ninja of Train
Ninja of TrainNinja of Train
Ninja of Train
 
C co c_team 13425_assignmentone-5
C co c_team 13425_assignmentone-5C co c_team 13425_assignmentone-5
C co c_team 13425_assignmentone-5
 
Supplemental Information Yoon Seok Choi
Supplemental Information Yoon Seok ChoiSupplemental Information Yoon Seok Choi
Supplemental Information Yoon Seok Choi
 
Introduction of operating system(latest)
Introduction of operating system(latest)Introduction of operating system(latest)
Introduction of operating system(latest)
 
Edad media
Edad mediaEdad media
Edad media
 
Learning and living pedagogies of the home
Learning and living pedagogies of the homeLearning and living pedagogies of the home
Learning and living pedagogies of the home
 
Edad moderna
Edad modernaEdad moderna
Edad moderna
 
Wilco Construction Project Presentation
Wilco Construction Project PresentationWilco Construction Project Presentation
Wilco Construction Project Presentation
 
Together
TogetherTogether
Together
 
Edad antigua
Edad antiguaEdad antigua
Edad antigua
 
Prehistoria
PrehistoriaPrehistoria
Prehistoria
 
Primera guerra mundial
Primera guerra mundialPrimera guerra mundial
Primera guerra mundial
 
12200786 pss7
12200786 pss712200786 pss7
12200786 pss7
 
Edad contemporanea
Edad contemporaneaEdad contemporanea
Edad contemporanea
 
Hernia
HerniaHernia
Hernia
 
Poverty and world hunger
Poverty and world hungerPoverty and world hunger
Poverty and world hunger
 
Mitologia griega
Mitologia griegaMitologia griega
Mitologia griega
 
Asian paints
Asian paintsAsian paints
Asian paints
 

More from tomerun

More from tomerun (7)

Mastermind
MastermindMastermind
Mastermind
 
U・N・C・O
U・N・C・OU・N・C・O
U・N・C・O
 
Bitmap
BitmapBitmap
Bitmap
 
Vinculum
VinculumVinculum
Vinculum
 
Cards
CardsCards
Cards
 
Match
MatchMatch
Match
 
Contest
ContestContest
Contest
 

Cheat

  • 1. Don't Think Seriously! Writer: komiya
  • 2. 問題概要 ● 数列Aが次のように定義される。 A[1] = 0 A[2] = 1 A[i+2] = A[i+1]^2 + A[i]^2 ● A[n] % Mを求めよ。 ● n < 2^31 ● M = 1999 or 10^9 + 7
  • 3. 部分点解法 ● A[i]は直前2項だけで決まる。 ● 直前2項の mod Mでの値の組は、たかだか M^2個しかない。 ● 鳩ノ巣原理より、M^2回程度回せば必ずルー プを検出できる。 ● ループを見つけたら、その周期の長さを利用 してA[n]での値を求めることができる。
  • 4. 満点解法 ● ローカルで計算して埋め込む。 ● もちろん全部埋め込むのは無理なので、適当 な箇所の連続する2項を埋め込む。 ● 埋め込み用データは、マシンスペックにもよる が1~5分程度で用意できる。