- 12
-
gimmepoint
- 조회 수 140
저의 수학을 사랑하는 (소위 이과충이라고 불리는) 친구가 이것을 학교 여러곳에 뿌렸습니다.
그리고 저는 이 문제를 풀었습니다
방법은 이렇습니다
#include<iostream>
using namespace std;
#define max 6
int dot[max];
int so;
int pow(int n,int a)
{
int n1 = n;
for(int i=1;i<a;i++)
n1 *= n;
return n1;
}
int ant(int n)
{
if(dot[n-1] != dot[n-2]) /// promising
{
if(n == max)
{
for(int i=0;i<max;i++)
cout << dot[i] << ' ';
cout << endl;
//cout << "so++" << endl;
if(dot[max-1] == 1)
{
//cout << "so--" << endl;
so--;
}
so++;
return 0;
}
else
{
for(int i=1;i<=4;i++)
{
dot[n] = i;
ant(n+1);
}
}
}
}
int main()
{
ant(0);
cout << pow(3,max) << " \ " << so;
}
여기서 나온 값에 1/3 배 했습니다.
ㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋ
또한 저는 이런 문제를 풀고 있습니다.
제가 짠 코드는 이렇습니다.
#include<iostream>
using namespace std;
int a[5][5];
int c;
bool promiseing(int x,int y)
{
if(y >= 2 && x == 1)
{
x = 4;
y--;
}
else
x--;
if(a[x][y]*a[x-1][y] == 0 || a[x][y]*a[x][y-1] == 0)
return true;
else
return false;
}
int write(int x,int y)
{
if(promiseing(x,y))
{
if(y == 5)
{
for(int i=1;i<5;i++)
{
for(int j=1;j<5;j++)
{
cout << a[i][j] << ' ';
}
cout << endl;
}
cout << endl;
c++;
return 0;
}
else
{
if(x == 5)
{
write(1,y+1);
}
else
{
for(int i=0;i<=1;i++)
a[x][y] = i;
write(x+1,y);
}
}
}
}
int main()
{
write(1,1);
cout << c;
}
근데 안 돌아갑니다.
ㅠㅠ
작성자
댓글 12
![profile image](/files/member_extra_info/profile_image/336/354/354336.png?t=1624451130)
![comment menu](/modules/board/skins/comely_board/images/icn_more.png)
![title : 대한민국 국기 title: 대한민국 국기](https://studyforus.com/./files/iconshop/5e6a5732aa3e4f353e2c3dbcdd6ea333.gif)
누구에 대한 말인가요?
![comment menu](/modules/board/skins/comely_board/images/icn_more.png)
![profile image](/files/member_extra_info/profile_image/336/354/354336.png?t=1624451130)
당신에겟!
![comment menu](/modules/board/skins/comely_board/images/icn_more.png)
![title : 대한민국 국기 title: 대한민국 국기](https://studyforus.com/./files/iconshop/5e6a5732aa3e4f353e2c3dbcdd6ea333.gif)
우왓 감사
![comment menu](/modules/board/skins/comely_board/images/icn_more.png)
![profile image](/files/member_extra_info/profile_image/845/172/172845.png?t=1690820334)
오 C언어로 수학 문제를 푸셨군요! 그 친구 적잖이 당황했겠는데요 ㅋㅋㅋ
![comment menu](/modules/board/skins/comely_board/images/icn_more.png)
![title : 대한민국 국기 title: 대한민국 국기](https://studyforus.com/./files/iconshop/5e6a5732aa3e4f353e2c3dbcdd6ea333.gif)
아직 보여주진 않았습니다.
이제 내일 보여줘야죠
ㅋㅋㅋㅋ
![comment menu](/modules/board/skins/comely_board/images/icn_more.png)
![profile image](/files/member_extra_info/profile_image/845/172/172845.png?t=1690820334)
아 그렇군요 ㅋㅋㅋ 후기 올려주세요!
![comment menu](/modules/board/skins/comely_board/images/icn_more.png)
![title : 대한민국 국기 title: 대한민국 국기](https://studyforus.com/./files/iconshop/5e6a5732aa3e4f353e2c3dbcdd6ea333.gif)
넵
(제가 기억 한다면.......)
![comment menu](/modules/board/skins/comely_board/images/icn_more.png)
![profile image](/files/member_extra_info/profile_image/145/220/220145.jpg?t=1603012768)
그래서 첫번째 답이 뭐라는거죠...?
출력되는 값은 729 0 인데, 729는 그냥 3^6 이고, 0은... 음....
경우의 수를 찾아보면 엄청 많네요. 연속으로 왕복도 가능하고....
두번째는 굳이 코드를 짤 필요도 없어보이군요.
0이 위치해야 하는 필수적인 위치를 체스판 모양으로 정해두면, 나머지 위치에는 0이든, 1이든 상관없으니...
(2^8)*2 = 512 네요.
![comment menu](/modules/board/skins/comely_board/images/icn_more.png)
![title : 대한민국 국기 title: 대한민국 국기](https://studyforus.com/./files/iconshop/5e6a5732aa3e4f353e2c3dbcdd6ea333.gif)
제가 첫번째 정답을 돌려보면 729 분에 546이 나옵니다.
두번째는 저도 처음에도 그렇거 생각했으나 뭔가 더 복잡할것 같더군요
(이 친구가 보통내기가 아니라서요)
![comment menu](/modules/board/skins/comely_board/images/icn_more.png)
![title : Fox title: Fox](https://studyforus.com/./files/iconshop/0068d0732376b81b3ea672dece854d51.png)
![profile image](/files/member_extra_info/profile_image/674/022/22674.png?t=1499320620)
아니 개미에게 무슨짓을?
개미가 불쌍해..~~
![comment menu](/modules/board/skins/comely_board/images/icn_more.png)
![title : 황금 서버 (30일) title: 황금 서버 (30일)](https://studyforus.com/./files/iconshop/33055af84f02ddedb19db038cdae0d2f.gif)
![profile image](/files/member_extra_info/profile_image/569/001/1569.png?t=1527385219)
4번 문제는 대칭성을 이용해서 풀면 되겠네요
![comment menu](/modules/board/skins/comely_board/images/icn_more.png)
워우...멋지신 분!