Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int g[81][10];
- #define j(x) g[x][0]
- #define u j(p)
- #define f(n)for(a=0;a<n;a++)
- int l(int p)
- {
- if(p>80)return 1;
- int a;
- f(9)g[p][a+1]=1;
- f(9)g[p][j(p/9*9+a)]=g[p][j(p%9+9*a)]=g[p][j(p%9/3*3+p/27*27+a/3*9+a%3)]=0;
- f(10)
- if(g[p][a])
- {
- u=!a?u:a;
- if(l(p+1))return printf(p%9?"%d ":"%d \n",u)|1;
- u=0;
- }
- return 0;
- }
- int main()
- {
- int y;
- char c[9];
- for(y=0;y<81&&(y%9!=0||scanf("%s",c)|1);y++)g[80-y][0]=(c[y%9]-48);
- l(0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement