æçµç®æ¨
æ´æ° ãä¸ããããã®ã§ã é ç¹ã®æ¨ã®åæ° mod 998244353 ãæ°ããããã ãé ç¹ã¯äºãã«åºå¥ãããªãã¨ããï¼ååãªæ¨ã®åæ°ãæ°ããï¼
âããã§ã
ãã®åé¡ã¯ ABC230Hã®è§£èª¬ã§çºå±åé¡ã¨ãã¦æ示ããã¦ãã¾ãããã®è¨äºã§ã¯ABC230Hã®ç解ã¯åæã¨ãã¾ãããã解説ãäºåã«èªãã§ããã¨ããããããããããã¾ããã
Editorial - AtCoder Beginner Contest 230
ã©ãã«ä»ãã®å ´å
ããããã¦ï¼Prüfer Sequence, ã±ã¤ãªã¼ã®å ¬å¼
ãã®è¨äºã§ã¯èª¬æããªãã®ã§ãâã§ã°ã°ã£ã¦ã¿ãã¨ãããã
æ ¹ä»ãæ¨ã®å ´å
æ´æ° ãä¸ããããã®ã§ã é ç¹ã®æ ¹ä»ãæ¨ã®åæ° mod 998244353 ãæ°ããããã ãé ç¹ã¯äºãã«åºå¥ãããªãã¨ããï¼ååãªæ ¹ä»ãæ¨ã®åæ°ãæ°ããï¼
ã©ãã«ãªãæ ¹ä»ãæ¨ã¨å¤ééåã®å¯¾å¿é¢ä¿
ãã¡ããã¡ãåçªã§ãããã©ãã«ãªãæ ¹ä»ãæ¨ã¨åè¦ç´ ãå¤ééåã§ããå¤ééåã¨ã®ä¸å¯¾ä¸å¯¾å¿ãåããã®ã§ããããèãã¾ãã
é ç¹æ°1ã®æ ¹ä»ãæ¨ï¼æ ¹ã ãã§ãï¼ã空ã®å¤ééå ã¨å¯¾å¿ä»ãã¾ãã ä¸è¬ã®æ ¹ä»ãæ¨ã«å¯¾ãã¦ã¯æ¬¡ã®è¦é ã§å帰çã«å¤ééåã対å¿ä»ãã¾ãï¼
æ ¹ã§ããé ç¹ã®ï¼ç´æ¥ã®ï¼åããããã«ã¤ãã¦ãåã®é¨åæ¨ã«å¯¾å¿ããå¤ééåã ã¨ããããã®ã¨ãããã®æ ¹ä»ãæ¨ã¨å¯¾å¿ããå¤ééå㯠ã¨ããã
ã¨ããããã§ãå¤ééåã®å¤ééåã¨ã©ãã«ãªãæ ¹ä»ãæ¨ã®å¯¾å¿é¢ä¿ãä½ãã¾ãããã©ãã«ãªãæ ¹ä»ãæ¨ãªã®ã§ãåã®é åºãªã©ã¯èãã¾ããã
ããã¯è¨ãæããã¨ãæ ¹ä»ãæ¨ã¨ã¯ããæ ¹ä»ãæ¨ã®å¤ééåã«æ ¹ãå ããæ§é ãã¨ããå帰çãªæ§è³ªãæã¤ã¨ããã¾ãã
æ ¹ä»ãæ¨ã®éåãç¹å¾´ã¥ãã
FPSï¼å½¢å¼çã¹ãç´æ°ï¼ãããã¾ããé å¼µã£ã¦é ãFPSã«ãã¦ããä¸åããã«æ¥ã¦ãã ãããFPSã«ãªãã¾ãããï¼
FPS ã¯ãä½ããã®çµåãçæ§é ããã¤ãªãã¸ã§ã¯ããæ°ããã¨ãã«ãã使ããã¾ããããã§ãããªãã¸ã§ã¯ãã並ã¹ãåããããªãã¸ã§ã¯ãã®å¤ééåããããã¾ãããã°æ°ãããã¨ãã§ãã¾ãã
ä¾é¡ï¼6é¢ããããã5åæ¯ããæ¯ã£ã¦åºãç®ãé ã«ä¸¦ã¹ã¦ã§ããé·ã5ãç·å i ã®æ°åã®åæ°ã ã¨ããã ã®æ¯é¢æ°ãæ±ããã
çãï¼
ããã¡ãã£ã¨ä¸è¬çã«ããã¨ãæ¯é¢æ°ã ã§ãããã®ã å並ã¹ã¦ã§ããåã®æ¯é¢æ°ã¯ ã«ãªãã¾ãã
ãã®ãã¯ããã¯ã使ãã°ãæ¯é¢æ°ãããã£ã¦ããã¨ããããã並ã¹ã¦ã§ããåã®æ¯é¢æ°ããããã¨ãããã¨ã«ãªãã¾ãããã£ããï¼
ãã¦ãæ ¹ä»ãæ¨ã®è©±ã«æ»ãã¾ããé ç¹æ° ã®ã©ãã«ãªãæ ¹ä»ãæ¨ã®åæ°ã ã¨ãã¾ãã ã®æ¯é¢æ° ãæ±ãããã§ãã
ããã§ãåæç¥èã¨ãã¦æ¬¡ã使ãã¾ãï¼
æ¯é¢æ°ã ã§ãããªãã¸ã§ã¯ããããªãå¤ééåã®æ¯é¢æ°ã¯
ãããªãã´ãã¤å¼ãåºã¦ã³ã£ãããããããããã¾ãããããã®ã¾ã¾çªãé²ã¿ã¾ãã
æ ¹ä»ãæ¨ã¯ããæ ¹ä»ãæ¨ã®å¤ééåã«ãæ ¹ãå ããæ§é ãã¨ãã¦ã¿ãªããã¨ãã§ãã¾ãããã£ã¦ã ã¯æ¬¡ã®é¢ä¿å¼ãæºããã¾ãã
æåã® ãæ ¹ã表ããå¾ãã®é¨åãæ ¹ä»ãæ¨ã®å¤ééåã表ãã¾ãããã¨ã¯ãã® ã®å é é ãæ±ããããã°è¯ãã§ãã
両辺ãå¾®åãã¦ã¿ã¾ããç©ã®å¾®åå ¬å¼ãæãåºãã¨ã
ã¨ãªãã¾ãã両辺㫠ããããã¨ã
ããã§ã ã ã¨ããã¾ãã
ãã®ã¨ãã ã§ãããã¨ããã
ãæãç«ã¤ãã¨ããããã¾ãã ã®å¤ã«ã¤ãã¦ã¯ã ãå ¨éã試ã㦠çªç®ã¾ã§ã®å¯ä¸ãæ±ããã°ããããã調åç´æ°ã®ãã¤ã§ã§ãã¾ãã
ãã£ã¦ã ããé çªã« ã漸åå¼ã«å¾ã£ã¦æ±ããã°ããã®ã§ã ã® é ãã¾ã§ãåå²çµ±æ²»FFTããªã³ã©ã¤ã³ç³ã¿è¾¼ã¿ãç¨ãããã¨ã«ãã£ã¦ ã§æ±ãããã¨ãã§ãã¾ãã
å®éã«å®è£ ãã¾ãããããªã³ã©ã¤ã³ç³ã¿è¾¼ã¿ã¯kiriãããããåãããã³ã¼ãã使ç¨ãã¾ãã
âkiriããã«ãããªã³ã©ã¤ã³ç³ã¿è¾¼ã¿ã®è¨äº
å®éã«å®è£ ãããã®ãä¸ã®ãªã³ã¯å ã®ã³ã¼ãã¨ãªãã¾ããNãæ¨æºå ¥åã§ä¸ããã¨N以ä¸ã«ã¤ãã¦ã®çµæãåºåãã¾ããå®éã«N = 20 ãªã©ã§è©¦ãã¦ã¿ãã¨ãA000081ã¨ä¸è´ããçµæãå¾ããã¾ããï¼ãããã大ãããªãã¨mod998244353ãã¨ã£ã¦ããã®ã§ä¸è´ããªããªãã¾ãï¼
ã¨ãããã¨ã§ã é ç¹ã®ã©ãã«ãªãæ ¹ä»ãæ¨ã®åæ°ãæ°ãããã¨ãã§ãã¾ããã
æ ¹ãªãæ¨ã®å ´å
ã©ãã«ãªãæ ¹ãªãæ¨ã®æ¯é¢æ° ã¨ã©ãã«ãªãæ ¹ä»ãæ¨ã®æ¯é¢æ° ã«ã¤ãã¦ã
ã¨ããé¢ä¿ãæãç«ã¡ã¾ãã
ããã証æããããã«ãæ ¹ãªãæ¨ã®éå¿ãå®ç¾©ãã¾ããããé ç¹æ° ã®æ¨ã®éå¿ã¨ã¯ã以ä¸ã®æ¡ä»¶ãæºããé ç¹ã§ãã
éå¿ ãæ ¹ã¨ããã¨ãã ã®ã©ã®åã®é¨åæ¨ã®ãµã¤ãºã 以ä¸ã§ããã
ããã§ã¯è¨¼æãã¾ããããæ¨ã®éå¿ã«ã¤ãã¦ä»¥ä¸ã®äºå®ãæãç«ã¡ã¾ãã
æ¨ã®éå¿ã®åæ°ã¯ 1 åã¾ã㯠2 åãæ¨ã®éå¿ã 2 ååå¨ããã¨ãããããã¯é£æ¥ãã¦ããã
ã®å¶å¥ã§å ´ååãããã¾ããã¾ãã以ä¸ã§ã¯é ç¹æ° ã®æ ¹ä»ãæ¨ã®åæ°ã ã¨ããã¾ãã
N ãå¥æ°ã®å ´å
æ ¹ä»ãæ¨ãã¨ã£ãã¨ãããã®æ ¹ãï¼æ ¹ãªãæ¨ã«ãããï¼éå¿ã¨ ãªããªã å ´åãèãã¾ããããããã¯ãæ ¹ã®ï¼ç´æ¥ã®ï¼åã®é¨åæ¨ã§ãã£ã¦ããµã¤ãºã ãã大ãããã®ãåå¨ãããã¨ã¨åå¤ã§ãã
ãã£ã¦ãæ ¹ãéå¿ã¨ãªããªãæ¨ã¯ã ãªã ãã¨ã£ã¦ãã¦ãé ç¹æ° ã®æ ¹ä»ãæ¨ã®æ ¹ã«é ç¹æ° ã®æ ¹ä»ãæ¨ãä»ãããã®ã¨ãã¦æ§æã§ãã¾ãããã£ã¦ãæ ¹ãå¯ä¸ã®éå¿ã¨ãªã é ç¹ã®æ¨ã®åæ°ã¯ã
ã¨ãã¦æ±ãããã¨ãã§ãã¾ããã¾ãã ãå¥æ°ã®ã¨ããéå¿ã¯å¿ ã 1 åã§ãããã£ã¦ãæ ¹ãªãæ¨ã®åæ°ãããã¨çãããªããã¨ããããã¾ãã
N ãå¶æ°ã®å ´å
å¥æ°ã®å ´åã¨åæ§ã«ãæ ¹ãå¯ä¸ã®éå¿ã¨ãªã é ç¹ã®æ¨ã®åæ°ã¯ ã§ããé ç¹æ°ãå¶æ°ã®å ´åãããã«å ãã¦ãéå¿ã 2 ã¤ããæ¨ã®åæ°ã追å ã§æ°ãã¾ãã
é ç¹æ°ã ã§éå¿ã 2 ã¤ããæ¨ã¯ãé ç¹æ° ã®æ ¹ä»ãæ¨ã 2 ã¤åã£ã¦ãã¦ããããã®æ ¹å士ãã¤ãªãã§ä½ããã¨ãã§ãã¾ãããã£ã¦ããã®åæ°ã¯
ã¨ãã¦è¨ç®ãããã¨ãã§ãã¾ãã
ãã£ã¦ãæ ¹ãªãæ¨ã®åæ°ã¯
ã¨ãã¦è¨ç®ã§ãã¾ãã
æ ¹ãªãæ¨ãå®è£
以ä¸ã®å¶æ°ã®å ´åãå¥æ°ã®å ´åãåããã¦ãFPSã§æ¸ãç´ãã¨ä¸è¨ã®å¼
ãå¾ããã¾ãã
ã®é¨åã¯ç³ã¿è¾¼ã¿ã§è¨ç®ã§ããã®ã§ã ãã ã ã§æ±ãããã¨ãã§ãã¾ãã
ãã£ã¦ãã©ãã«ãªãæ ¹ãªãæ¨ã®åæ°ãæ°ãããã¨ãã§ãã¾ããã
å®éã«ã³ã¼ããæ¸ãããã®ã以ä¸ã§ãã
OEISã«ããã¨ãæ ¹ä»ãæ¨ã®æ㯠0 é ç¹ã§çãã 0 ã ã£ãã®ã«ãæ ¹ãªãæ¨ã®ã»ãã¯çãã 1 ã«ãªãããã§ããç´æçã«ã¯ä¸¡æ¹ 1 ãèªç¶ãããªã®ã§ãããæ ¹ä»ãæ¨ã¯æ ¹ãé¸ã¶æ¹æ³ã®åæ°ã«ãªãã®ã§ 0 ãªãã§ããããï¼ããããããªãã§ã
ãã¨ãã
Bullion ã解ããã¤ãã§ã«ä¸åãã£ããã¨ãããã®ã§ãããå®å ¨ã«å¿å´ãã¦ããã¤ããã£ãã§ãã