标签:stdio.h class iostream memory char* top ret cin 不能
题意:生日蛋糕上面有2N草莓,怎么切能够将蛋糕和草莓平分成俩份,直接枚举,A和B,草莓不能落在直线上
#include <iostream> #include <stdio.h> #include<memory.h> using namespace std; #define null NULL int N = 110; int f(int a, int b, int x, int y) { return a * x + b * y; } int main(int argc, char* argv[]) { //freopen("C:\\Users\\zzzzz\\Desktop\\1.txt", "r", stdin); int n; int x[N]; int y[N]; while (cin >> n) { if (n == 0) return 0; for (int i = 0; i < 2 * n; i++) cin >> x[i] >> y[i]; int ok = 1; for (int a = -500; a <= 500 && ok; a++) { for (int b = -500; b <= 500 && ok; b++) { int l = 0, r = 0; for (int i = 0; i < 2 * n; i++) { int k = f(a, b, x[i], y[i]); if (k == 0) break; if (k < 0) l++; else r++; } if (l == n && r == n) { cout << a << " " << b << endl; ok = 0; } } } } return 0; }
标签:stdio.h class iostream memory char* top ret cin 不能
原文地址:http://www.cnblogs.com/shuiyonglewodezzzzz/p/7672922.html