![]() |
China DOS Union-- Unite DOS · Advance DOS · Grow DOS --Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum |
| Guest | Log in | Register | Members | Search | China DOS Union |
|
中国DOS联盟论坛 The time now is 2026-08-10 16:58 |
47,811 topics / 349,897 posts / today 0 new / 48,256 members |
| DOS批处理 & 脚本技术(批处理室) » Use exhaustive search to solve an Olympiad math problem? |
| Printable Version 937 / 9 |
| Floor1 pykacha | Posted 2008-11-17 17:35 |
| 初级用户 Posts 73 Credits 156 | |
|
The problem is like this: there is a four-digit number. The first digit is the number of 0s in this number, the second digit is the number of 1s in this number, the third digit is the number of 2s in this number, and the fourth digit is the number of 3s in this number. Find this number.
|
|
| Floor2 pusofalse | Posted 2008-11-17 19:28 |
| 银牌会员 Posts 646 Credits 1,604 | |
|
- - ||| I actually didn't even understand what it means...
|
|
| Floor3 balinger | Posted 2008-11-17 19:47 |
| 中级用户 Posts 115 Credits 356 | |
| Floor4 HAT | Posted 2008-11-17 20:14 |
| 版主 Posts 5,017 Credits 9,023 | |
|
Olympiad math problems probably shouldn't be done with exhaustive search, otherwise the Olympiad math teacher would harshly criticize you :)
|
|
| Floor5 balinger | Posted 2008-11-17 20:30 |
| 中级用户 Posts 115 Credits 356 | |
|
"The first digit is the number of 0s in this number", so the first digit definitely cannot be 0, otherwise it's a contradiction.
|
|
| Floor6 lianjiang2004 | Posted 2008-11-17 21:06 |
| 金牌会员 Posts 1,884 Credits 3,946 | |
|
Not sure whether the units digit is the first digit, or the thousands digit is the first digit.
|
|
| Floor7 pykacha | Posted 2008-11-18 00:14 |
| 初级用户 Posts 73 Credits 156 | |
|
Reply #3 is correct, but it doesn't seem to have been calculated with P.
The first digit cannot be 0, otherwise it would be a three-digit number. Also, that's if "the first digit" in the problem means counting from the left. If the first digit means counting from the right, then I don't know what the answer is. Still hope it can be done with P |
|
| Floor8 lianjiang2004 | Posted 2008-11-18 08:49 |
| 金牌会员 Posts 1,884 Credits 3,946 | |
|
If the first digit is counted from the right, then it's 0.003
|
|
| Floor9 balinger | Posted 2008-11-18 15:19 |
| 中级用户 Posts 115 Credits 356 | |
|
The first digit means counting from the left. Answers: 1210 2020
If the first digit is counted from the right, then 0202 0121. If the first digit cannot be 0, otherwise it would be a three-digit number, then there is no solution. Below is for counting the first digit from the left @echo off SETLOCAL ENABLEDELAYEDEXPANSION for /l %%a in (0,1,3) do ( for /l %%b in (0,1,3) do ( for /l %%c in (0,1,3) do ( for /l %%d in (0,1,3) do ( set n=0 for /l %%e in (0,1,3) do ( set m%%e=0 if %%a==%%e set /a m%%e+=1 if %%b==%%e set /a m%%e+=1 if %%c==%%e set /a m%%e+=1 if %%d==%%e set /a m%%e+=1 ) if !m0!==%%a set /a n+=1 if !m1!==%%b set /a n+=1 if !m2!==%%c set /a n+=1 if !m3!==%%d set /a n+=1 if !n!==4 echo %%a%%b%%c%%d )))) ENDLOCAL pause |
|
| Floor10 HAT | Posted 2008-11-18 15:56 |
| 版主 Posts 5,017 Credits 9,023 | |
|
Shouldn't the outermost for start from 0?
|
|
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |