2023-01-01ãã1å¹´éã®è¨äºä¸è¦§
ä»å¹´ããã£ã¦ã¿ã¾ã rsk0315.hatenablog.com ä»å¹´æ¸ãããã® ã«ã¹ã®è¨äº ã¯ã¦ãªããã°é¢é£ æ°ã¾ããã¢ã«ã´ãªãºã ãããããã·ãªã¼ãº æ¯ãè¿ã DP é¢é£ æ°å¼ãã¡ããã¡ã ãã©ãã¯ããã¯ã¹ã®ãåå¼· æµ®åå°æ°ç¹æ° ä»å¹´è²·ã£ããã® æ¥å¹´ã«åã㦠競ããä»¥å¤ ãâ¦
ã風åã§æãã¤ããã·ãªã¼ãºã§ãã ã§ããæä½ã¯æ¬¡ã®éãã§ãã $\texttt{new}()$ $â $ ã§åæåãã $S.\texttt{insert}(x)$ $S â S ⪠\{x\}$ ã§æ´æ°ãã $S.\texttt{remove}(x)$ $S â S \smallsetminus \{x\}$ ã§æ´æ°ãã $S.\texttt{less}(a)$ $\max {\{xââ¦
å°æ°ç¹ä»¥ä¸ãé«ã 2 æ¡ã¾ã§ããå¤ãåé²è¡¨è¨ã§ä¸ããããã¨ããããããæµ®åå°æ°ç¹æ°åã« parse ãã¦ãã 100 åããããã¨ã§ãå ã®å¤ã®å°æ°ç¹ã 2 ã¤ã¶ãåããããã®ã«ã§ãã¾ããï¼ã¨ãã話ã§ãã >>> print(f'{float("10.00")*100:.100g}') 1000 >>> prinâ¦
符å·ãªãã® 64-bit æ´æ°åã®å¤ã«é¢ãã¦å¹³æ¹æ ¹ãè¨ç®ãããå±é¢ã¯ããããããã¾ãã ããããå¤ãã®è¨èªã§ã¯ãã®ããã®é¢æ°ãç¨æããã¦ããããæµ®åå°æ°ç¹æ°åç¨ã®ã¡ã½ããã使ã人ãå¤ããã¾ãã ä»åã¯ãããããæ¹éã妥å½ãï¼ï¼èª¤å·®ãåºãããã¨ãè¸ã¾â¦
ä»®æ°é¨ã®ç²¾åº¦ã 53 bits ã®æµ®åå°æ°ç¹æ°åã§è¨ç®ããã¨ä¸è¨ã®ããã«ãªãã¾ãã >>> 1 / 49 * 49 0.9999999999999999 >>> f'{1/49*49:.100g}' '0.99999999999999988897769753748434595763683319091796875' ä»åã¯ããã«ã¤ãã¦æãä¸ãã¾ãã è¨æ³ã»åæç¥è â¦
ããã double ã§è¨ç®ããã¨ãã«å¸¸ã«çãããªãã¾ããï¼ã¨ããã¯ã¤ãºã§ãã n 㯠double ã§è¡¨ããæ´æ°ã§ãããã¨ã«ãã¾ãã çã >>> 6755399441055749 / 10 675539944105574.9 >>> 6755399441055749 * 0.1 675539944105575.0 ãããåè ã® floor ã¨å¾è ã® fâ¦
atcoder.jp å°å ¥ ããã® long double 解æ³ã«ã¤ãã¦ã®è©±ã§ããä¸è¨ã®ãããªè§£æ³ã§ãã #include <cmath> #include <cstdio> constexpr long double eps = /* ??? */; bool ok(long double a, long double b, long double c) { return std::sqrt(a) + std::sqrt(b) + eps < st</cstdio></cmath>â¦
judge.yosupo.jp ãã¡ãã§ããããã解ãã¢ã«ã´ãªãºã ã®ä¸ã¤ã¨ãã¦ä¸è¨ãããã¾ãã Kolpakov, Roman, and Gregory Kucherov. "Finding maximal repetitions in a word in linear time." In 40th Annual Symposium on Foundations of Computer Science (Cat.â¦
èæ¯ã¨ãã¦ã¯ããã¡ãã®è¨äºã§ãã rsk0315.hatenablog.com 1431655766, 1717986920, 1431655782, 1431655768, 1840700272, 1431655966, -1431655056 ãªã©ãã¾ãã¾ãªãã¸ãã¯ãã³ãã¼ãç»å ´ãã¾ãã ã$x$ ã $3$ ã®åæ°ã§ãããã¨ãããã£ã¦ããã¨ãã$1431â¦
Clang ã $\sum_{i=0}^n i$ ã $n(n+1)/2$ ã«ãã¦ããããã¨ã¯æåã§ã*1ã ã¾ãã$\sum_{i=0}^n i^2$ ã $n(n+1)(2n+1)/6$ ã«ãã¦ããã¾ãã ãã®éç¨ã§ã¯ã unsigned v1 = n * (n - 1) * (n - 2) / 2 * 1431655766u; unsigned v2 = n * (n - 1) / 2; returâ¦
ã¿ã¤ãã«æ¬ãã«ãã´ãªæ¬ã§ âM ãæ¼ãã¨ãä½ããã®åãã¯ãããã¦è¨äºãæ稿ããã¦ãã¾ãããã¶ãªãï¼ä¸æï¼ã å³ä¸ããä¸æ¸ããæ´æ°ããããï¼æ稿å¾ç·¨éä¸ã®ï¼ãæ´æ°ãããã§ãã£ã¦ããããªãã
競ãã er ã¯ããè¨ç®éã®è¦ç©ããããã¾ãããããããã®è¨ç®é㯠$O(\dots)$ ãªã®ã§ååé«éã§ãããã¨ãã£ãå ·åã§ä¸ããæãããã¨ãå¤ãã§ãã ã¾ãããããããã®è¨ç®é㯠$\Omega(\dots)$ ãªã®ã§ TLE ããããã¨ãã£ãå ·åã§ä¸ããæãããã¨ããã°ãâ¦
â ããã hello ã«ãªã£ã¦ããã°åã¡ zzz â æ¬ä¼¼ã³ã¼ãã render ããã¦ããã°åã¡ function $\textsc{Identity}(x)\colon$ return $x$
å æ¥ãä¸è¨ã®è¨äºã§ããããµãã¯åé¡ã® DP ãæç´ã«çºãã¾ããã rsk0315.hatenablog.com ä»åã¯ãããããµãã¯åé¡ã«éããæ§ã 㪠DP ãæç´ã«çºããåã§ãã ãââï¼ä½ããã®éåï¼ã®æ大å¤ãã®ããã«è¨ç®ãããââã®é¨åã«ã¤ãã¦èãã¦ããã¾ãã ãã¡ãã â¦
å ¸åç㪠DP ã®å®è£ ã®å±æ§ã®ä¸ã¤ã¨ãã¦ãé ã DPã»ããã DP ã¨å¼ã°ãã¦ãããã®ãããã¾ãã ããã DP ãéãã DP ã¨å¼ã¶æ´¾é¥ããã£ãæ°ããã¾ãããããã§ã¯å称ã«ã¤ãã¦ã®è°è«ã¯ãã¾ããã å°å ¥ 主張 ä¾ ããããµãã¯åé¡ Eratosthenes ã®ç¯© åæ°ã®æå¾ â¦
ããæ£ç¢ºã«ã¯ãABC ã® AâE ãããã¾ããã èªå·±è¯å®æãä½ãããä½ã ãããã¾ãããã¨ããã¨ãã«ãã¾ã ããã¦ãªãã£ãã®ããã¨ãã声ãèªåã®ä¸ããèããã¦ããã¿ã¤ãã®äººããããªãã«ããã®ã§ã¯ãªãã§ããããããã³ã¡ããã¯ãããã人ã§ãã ä»ã®äººãããâ¦
ABC 204 E ã«é¢é£ãã¾ãã å®ç¾© è¡¨è¨ æå³ ä¾ $\floor{x}$ $x$ 以ä¸ã®æ大ã®æ´æ° $\floor{3.1} = 3$, $\floor{2.7} = 2$, $\floor{-2.2} = -3$, $\floor{2} = 2$ $\ceil{x}$ $x$ 以ä¸ã®æå°ã®æ´æ° $\ceil{3.1} = 4$, $\ceil{2.7} = 3$, $\ceil{-2.2} = -2$, â¦
åçè¨ç»æ³ (dynamic programming, DP) ã¯ã¤ã¡ã¼ã¸ã»ã¡ã³ã¿ã«ã¢ãã«ãæ´ãã¾ã§ã®ãã¼ãã«ãä¸ã é«ããããªæ°ããã¾ãã ä¸ä¾ã示ãã¾ãããå¿ ãããå ¨é¨ã®åé¡ãä¸è²«ãã¦èª¬æã§ããã¨ã¯éããªãã®ã§ãããã¤ãã®ã¤ã¡ã¼ã¸ãæã£ã¦ããã¨ããããããã¾ããï¼â¦
æè¿è©±é¡ã®å½¢å¼çåªç´æ° (FPS) ã§ããæè¿ã¨è¨ãã¤ã¤ 4 å¹´ãããåããæµè¡ãå§ãã¦ããæ°ããã¾ããå½æã¯ãæ¯é¢æ°ãã¨å¼ãã§ãã人ãå¤ãã£ãæ°ããã¾ãã ä»åã¯ãFPS ã§èå¯ããã¦ãã¦ã$\frac{\dd}{\dd x}y = f(y)$ ãªã FPS $y(x)$ ã«å¯¾ã㦠$y(x)\bmoâ¦
ä½ããã®é åºãæã£ãå T: Ord ããã£ã¦ãããã«é¢ããä½ããã®ï¼å¤éï¼éåã®ä¸å¤®å¤ãæ±ããã©ã¤ãã©ãªãä½ãããã¨ãã¾ãã ãã¨ãã°åã«é å a: [T] ã®ä¸ããä¸å¤®å¤ãæ¢ãã ãã ã£ãããa: [T], b: [T] ãã a[i] + b[j] ã¨ãã¦èãããããã®ã®ä¸å¤®å¤ (â¦
ã«ãã´ãªã¼æ©è½ã使ã£ã¦ããªãã£ãã®ã§ã使ãã¨ä¾¿å©ãªã®ã§ã¯ï¼ã¨æãã¾ãããåè«ã¨ã¯é¢ä¿ããªãããããã¾ããã
ã¡ããã¨ç解ãã¦ããªã人ã大åã ã¨æã£ã¦ãã¾ãããããã¯ãæ³ãç´ æ°ã®å ´åã«éå¦ç¿ãã¦ãæ³ãåææ°ã«ãªã£ãé端ã«ä¸å®ã«ãªã人ãå¤ãã§ããã*1ã 競ãã er ã®ä¸å¤§å¾æåéã¨ãã¦ãè¨ç®éåæ¸ããmod ãªãã¨ãã®æ°ãä¸ããããªããããããã¯ããªã®ã«ãâ¦
ãããããã¨å ¨äººé¡ç¥ã£ã¦ããããããã¾ããã $\gdef\lpf{\operatorname{lpf}}$ $\gdef\ord{\operatorname{ord}}$ å°å ¥ åè¨ç® é«éå å®è£ ãã¾ã Euler ã® totient é¢æ° ç´æ°åæ ããã å°å ¥ 以ä¸ãæ´æ° $i$ ã®æå°ç´ å æ° (least prime factor; LPF) ãâ¦
ã¯ã¤ãºã§ãã$p/q \equiv 714236805 \pmod{998244353}$ ãæºããäºãã«ç´ ãªæ´æ°ã®ã㢠$(p, q)$ ã¯ãªãã§ããããã çã㯠$(113, 355)$ ã§ã*1ãä»æ¥ã®è©±ã¯ããããä¸è¬çã«æ±ããæ¹æ³ã§ãã è£è©± $1/3 \equiv 332748118$ ã¿ãããªã®ã ã¨ãã¿ã¼ã³ãããã§â¦
$n^2+2n+1 = (n+1)^2$ ã§ãã$n = -1$, $n = 0$ ã®ã¨ã $0$, $1$ ã§ããç´ æ°ã§ã¯ããã¾ããã$n \ge 1$ ã®ã¨ãç´ æ°äºã¤ä»¥ä¸ã®ç©ã¨ãªãã®ã§ç´ æ°ã§ã¯ããã¾ããã ã¾ãã$n \lt -1$ ã«ã¤ãã¦ãåæ§ã«ç´ æ°ã§ãªããã¨ããããã¾ãã ãã£ã¦ã$n^2+2n+1$ åã®ç´ æ°â¦
å°å ¥ rsk0315.hatenablog.com ãããã話ã¯ãã*1ãã§ãããæåãããã°ãããããæ¸ãæ¹ããã¦ããã¦ããã°ãåºãã¼ãã¨è¨ããã¦ãããã¯ããã¨ãªã£ã¦ãã¾ãã®ã§ãããããã®ãæ§ãããããã®ãã¨ã¯ããã¹ãã ã¨æãã¾ãã æ¸ãæ¹ãæªãããã§ãååã«è¤éâ¦
æéãéããã®ã§å ¬éãçµäºãã¾ããã
詳ãã解説編ããããã¯ãããã¾ããã ä¸è¨ã®ãããªç¶æ³ã«å¯¾ããå¥ã®çã§ãã rsk0315.hatenablog.com rsk0315.hatenablog.com å°å ¥ ä»åã¯ãæµ®åå°æ°ç¹æ°ããããã使ããªãæ¹éã§èãã¾ãã ããï¼èªåã§æ±ºããï¼ä¸é $b$ ã«å¯¾ãã¦ãåæ¯ã $b$ 以ä¸ã®ï¼â¦
åå ãã¦ãã¾ããã ãã³ã¡ããã§ã pic.twitter.com/thrbw3oZYBâ ãã³ã¡ãã (@rsk0315_h4x) 2023å¹´3æ18æ¥ ãåå è¨ã«è¼ããç¨ã®ç»åãè¼ãã¦ããã¨ãåå è¨ã«è¼ããã®ã楽ã«ãªããã¨ããã®ãæãåºããã®ã§æ®ã£ã¦ãã¾ããã äºé¸ B 㧠G ã解ãã¦ããæãâ¦
ç¡è¦ãããã³ã³ãã¤ã©ã¡ããããããããã§ãã ã¨ã¯ããããããã®ã³ã¼ããããªã£ã¦ãããã¨ããè¦åã®ä»æ¹ã ãããã¦ãï¼ç¹ã«åå¿è ãï¼å°ã£ã¦ãã¾ãã®ã¯å½ç¶ããªã¨ããæ°ããã¾ãã ã³ã³ãã¤ã©ãæ°ã«ãã¦ããã¦ããçç±ããå®éã«ãã°ã£ã¦ããã³ã¼ãã§ãâ¦