Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
为什么WA, 请看看#include <iostream> #include <sstream> #include <string> #include <vector> #include <set> #include <map> #include <algorithm> #include <cstdio> #include <cstdlib> #include <cmath> #include <math.h> #include <string.h> #include <stdlib.h> using namespace std; #define REP(i, n) for(int i = 0; i<(n); i++) #define abs(a) ((a) >= 0 ? (a) : -(a)) #define inf 999999999 typedef vector<int> VI; typedef vector<string> VS; typedef long long i64; typedef unsigned long long u64; int v[6][6]; int dp[1000000]; int dx[] = {-1, 0, 1, 0}; int dy[] = {0, 1, 0, -1}; void go(int num, int digit, int x, int y) { if (digit == 6) { if(dp[num]) return; else dp[num] = 1; return; } for (int i = 0; i < 4; i++) { int rx = x+dx[i]; int ry = y+dy[i]; if (rx>=0 && rx<5 && ry>0 &&ry<5) go(num*10+v[rx][ry], digit+1, rx, ry); } return; } int main() { for (int i = 0; i < 5; i++) for (int j = 0; j < 5; j++) scanf("%d", &v[i][j]); for (int i = 0; i < 5; i++) for (int j = 0; j <5; j++) go(v[i][j], 1, i, j); int res = 0; for (int i = 0; i < 1000000; i++) res+=dp[i]; printf("%d\n", res); } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator