11ã®åæ°ã®å¤å®æ³
ãã®æ¹æ³ã§ã¯ãåã±ã¿ã1ã¤ãã¤é£ã°ãã¦è¶³ããããã¨1ã¤ã®èªç¶æ°ãã2ã¤ã®åè¨å¤ãåºã¦ãã¾ãããã®åè¨å¤ãä¸è´ããããå·®ã11ã®åæ°ã®ã¨ãããã¨ã®æ°ã11ã®åæ°ãªã®ã§ãã
(ç¥)
ãªããããªãããæ¬å½ã¯ãããªã«é£ããããã¾ãããâ¦â¦ã
ç§ãããã«ã¼ãããªãã®ã§æã§è¨¼æããæ¹ãï¾ï¾ï½½
ã¤ãé«ï¼ã®ã¨ããé¢ç½ãã£ã¦ããããªæ°ã®å¤å®æ³è¦ã¤ãã¦éãã§ã¾ããã
ï¼ããããï¼
ä»»æã®éè² æ´æ°Nã
Nï¼Î£(102n+1an + 102nbn)
ã§è¡¨ããï¼n, an, bnã¯éè² æ´æ°)
102nï¼100nï¼99(100n-1+100n-2+...+1)+1
102n+1ï¼10*100nï¼10*99(100n-1+100n-2+...+1)+10 ï¼ 10*99(100n-1+100n-2+...+1)+11-1
ãªã®ã§
Nï¼Î£(10*99(100n-1+100n-2+...+1)an + 11an + 99(100n-1+100n-2+...+1)bn) +Σ(bn-an)
â¡Î£bi-Σaj (mod 11)
ï¼ããã¾ã§ï¼
ãã¨å人çã«ã¯ãã°ã¼ã£ã¨ï¼çµè¶³ãã¦ãã¨ã§å¼ãããã足ãã¦å¼ãã¦è¶³ãã¦å¼ãã¦â¦ã¨ããæ¹ã好ã¿ãªã®ã§ï¼11以å¤ã®æ°ã®å¤å®æ¹æ³ããé©å½ã«ä¿æ°ãããã¤ã¤ããããã¨ã§ããå ´åãå¤ããï¼ããªã®ã§è¨ç®ã¡ãã£ã¨ããã£ã¦ã¿ã¾ããã以ä¸ã®ã³ã¼ããjmukããã®ã«ä¸æ¸ããã¦ã¾ãã
import Test.QuickCheck newtype Rank = R Integer deriving Show data Op = Add | Sub deriving (Eq, Show) instance Arbitrary Rank where arbitrary = fmap (R . (`mod` 10)) arbitrary f :: [Rank] -> Integer f l = foldl (+) 0 $ zipWith (\(R x) n -> x * 10 ^ (n-1)) l [1..] g :: [Rank] -> Integer g rs = g1 0 rs Add g1 :: Integer -> [Rank] -> Op -> Integer g1 n [] _ = n g1 n (R v:rs) op | op == Add = g1 (n+v) rs Sub | op == Sub = g1 (n-v) rs Add c l = (f l `mod` 11 == 0) == (g l `mod` 11 == 0)
quickCheckã
*Main> quickCheck c OK, passed 100 tests.