é·æ´æ°ã®æãç®ã¯4æ¡ãã¤ã«ãããã°ç°¡åã§ãããããå²ãç®ã¯é£ããã§ããããã§ã¯ææããã¦ãã¾ããé¤æ°ã¯32ãããã®æ´æ°ã使ã£ã¦ã被é¤æ°ã4æ¡ã«åãã¦ãã¾ããããããé¤æ°ã¯æ大6æ¡ã§ãä½ããæ大6æ¡ã«ãªãã®ã§1ä¸åããã10æ¡ã«ãªã£ã¦ãªã¼ãã¼ããã¼ãã¾ãã
大ããã®æ¯è¼ã¯ãåã4æ¡ãã¤ã®åºåãã§æ¯è¼ãã¾ãã
:greater_equal if "%1" == "" exit /b 1 if %1 GTR %2 exit /b 1 if %1 LSS %2 exit /b 0 call :greater_equal %3 %4 %5 %6 exit /b %ERRORLEVEL%
æåã®4æ¡ãã¤ãæ¯è¼ãã¦ãåããªãã·ãããã¦èªåãå¼ã³åºãã¾ãã4ã¤ããå¼æ°ããªããã%5ã¯ãªãããã§ãããå¤ãã»ããããã¦ããªãã ãã§ä½¿ã£ã¦ãåé¡ãªãã§ãã4åç®ãå¼ã³åºãããã¨ãã«%1ãå¤ãã»ããããã¦ããªãã®ã§ãã®ã¨ãã¯çããã¨å¤å®ãã¾ãã
@echo off set N=600851475143 set n1=%N:~0,-8% if "%n1%" == "" set /a n1 = 0 set n2=%N:~-8,-4% if "%n2%" == "" set /a n2 = 0 set /a n3 = %N:~-4% set /a p = 2 :loop call :mod %n1% %n2% %n3% %p% if %ERRORLEVEL% NEQ 0 ( set /a p += 1 goto :loop ) rem // n /= p set /a r1 = %n1% %% %p% set /a n1 /= %p% set /a n2 = %r1% * 10000 + %n2% set /a r2 = %n2% %% %p% set /a n2 /= %p% set /a n3 = (%r2% * 10000 + %n3%) / %p% rem // q = p * p set /a p1 = %p% / 10000 set /a p2 = %p% %% 10000 set /a q3 = %p2% * %p2% set /a q2 = 2 * %p1% * %p2% + %q3% / 10000 set /a q3 = %q3% %% 10000 set /a q1 = %p1% * %p1% + %q2% / 10000 set /a q2 = %q2% %% 10000 call :greater_equal %n1% %q1% %n2% %q2% %n3% %q3% if %ERRORLEVEL% == 1 goto :loop call :greater_equal %n1% 0 %n2% 0 %n3% 2 if %ERRORLEVEL% == 1 ( call :echo_long %n1% %n2% %n3% ) else ( echo %p% ) exit /b 0 :mod setlocal set /a d = %4 set /a r = ((%1 %% %d% * 10000 + %2) %% %d% * 10000 + %3) %% %d% exit /b %r% :greater_equal if "%1" == "" exit /b 1 if %1 GTR %2 exit /b 1 if %1 LSS %2 exit /b 0 call :greater_equal %3 %4 %5 %6 exit /b %ERRORLEVEL% :echo_long setlocal set /a n = (%1 * 10000 + %2) * 10000 + %3 echo %n%