标签:alt bool max blank mic tps ret org style
好像
1 for (int i = 1; i <= n; i++) { 2 printf("%d\n", i); 3 return 0; 4 }
和
1 for (int i = 1; i <= n; i++) { 2 return 0, printf("%d\n", i); 3 }
是一样的。
调题 洛谷2484 时,发现似乎是这样的。
这样可以过样例
但是,去掉 return 后面的 printf 之后, 就变成了
样例中 ans 的初始值是 16
1 #include <cstdio> 2 3 const int MAXN = 107; 4 5 int n, m, sum, ans, a[MAXN][MAXN], co[MAXN][MAXN]; 6 7 bool check(int r, int c) { 8 if (sum % (r * c)) return 0; 9 10 for (int i = 1; i <= m; i++) 11 for (int j = 1; j <= n; j++) 12 co[i][j] = a[i][j]; 13 14 for (int i = 1; i <= m; i++) { 15 for (int j = 1; j <= n; j++) { 16 if (co[i][j]) { 17 for (int x = i; x <= i + r; i++) { 18 for (int y = j; y <= j + n; y++) { 19 if (co[x][y] < co[i][j]) return 0; 20 else co[x][y] -= co[i][j]; 21 } 22 } 23 } 24 } 25 } 26 27 for (int i = 1; i <= m; i++) { 28 for (int j = 1; j <= n; j++) { 29 if (co[i][j]) return 0; 30 } 31 } 32 return 1; 33 } 34 35 int main() { 36 scanf("%d%d", &m, &n); 37 38 for (int i = 1; i <= m; i++) 39 for (int j = 1; j <= n; j++) 40 scanf("%d", &a[i][j]), sum += a[i][j]; 41 42 ans = sum; 43 44 for (int i = 1; i <= n; i++) { 45 for (int j = 1; j <= n; j++) { 46 if (check(i, j)) { 47 if (sum / (i * j) < ans) ans = sum / (i * j); 48 } 49 } 50 } 51 52 printf("%d\n", ans); 53 return 0; 54 }
又试了一下:
会返回 2
标签:alt bool max blank mic tps ret org style
原文地址:http://www.cnblogs.com/ExileValley/p/7677117.html