标签:style blog class c code tar
#include <stdio.h> #include <string.h> int n, m; long long dp[305][305], ans[305][305]; int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); } int main() { for (int i = 1; i <= 300; i++) for (int j = 1; j <= 300; j++) dp[i][j] = dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - 1] + (gcd(i, j) == 1); for (int i = 1; i <= 300; i++) for (int j = 1; j <= 300; j++) ans[i][j] = ans[i - 1][j] + ans[i][j - 1] - ans[i - 1][j - 1] + dp[i][j] - dp[i / 2][j / 2]; while (~scanf("%d%d", &n, &m) && n || m) { printf("%lld\n", ans[n - 1][m - 1] * 2); } return 0; }
UVA 1393 - Highways (容斥原理计数),布布扣,bubuko.com
标签:style blog class c code tar
原文地址:http://blog.csdn.net/accelerator_/article/details/26132853