# Number BZOJ3275 最大流

1:存在正整数C，使a*a+b*b=c*c
2:gcd(a,b)=1

Sample Output22

Input

Output

Sample Input5 3 4 5 6 7

st 和奇数连边，ed 和偶数连边；

(有点最大权闭合子图的意思？

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<bitset>
#include<ctime>
#include<deque>
#include<stack>
#include<functional>
#include<sstream>
//#include<cctype>
//#pragma GCC optimize(2)
using namespace std;
#define maxn 300005
#define inf 0x3f3f3f3f
#define INF 9999999999
#define rdint(x) scanf("%d",&x)
#define rdllt(x) scanf("%lld",&x)
#define rdult(x) scanf("%lu",&x)
#define rdlf(x) scanf("%lf",&x)
#define rdstr(x) scanf("%s",x)
typedef long long  ll;
typedef unsigned long long ull;
typedef unsigned int U;
#define ms(x) memset((x),0,sizeof(x))
const long long int mod = 1e9 + 7;
#define Mod 1000000000
#define sq(x) (x)*(x)
#define eps 1e-3
typedef pair<int, int> pii;
#define pi acos(-1.0)
const int N = 1005;
#define REP(i,n) for(int i=0;i<(n);i++)
typedef pair<int, int> pii;
inline ll rd() {
ll x = 0;
char c = getchar();
bool f = false;
while (!isdigit(c)) {
if (c == '-') f = true;
c = getchar();
}
while (isdigit(c)) {
x = (x << 1) + (x << 3) + (c ^ 48);
c = getchar();
}
return f ? -x : x;
}

ll gcd(ll a, ll b) {
return b == 0 ? a : gcd(b, a%b);
}
ll sqr(ll x) { return x * x; }

/*ll ans;
ll exgcd(ll a, ll b, ll &x, ll &y) {
if (!b) {
x = 1; y = 0; return a;
}
ans = exgcd(b, a%b, x, y);
ll t = x; x = y; y = t - a / b * y;
return ans;
}
*/

ll qpow(ll a, ll b, ll c) {
ll ans = 1;
a = a % c;
while (b) {
if (b % 2)ans = ans * a%c;
b /= 2; a = a * a%c;
}
return ans;
}

int n, m;
int st, ed;
struct node {
int u, v, nxt, w;
}edge[maxn<<2];

void addedge(int u, int v, int w) {
edge[cnt].u = u; edge[cnt].v = v; edge[cnt].w = w;
}
int rk[maxn];

int bfs() {
queue<int>q;
ms(rk);
rk[st] = 1; q.push(st);
while (!q.empty()) {
int tmp = q.front(); q.pop();
for (int i = head[tmp]; i != -1; i = edge[i].nxt) {
int to = edge[i].v;
if (rk[to] || edge[i].w <= 0)continue;
rk[to] = rk[tmp] + 1; q.push(to);
}
}
return rk[ed];
}

int dfs(int u, int flow) {
if (u == ed)return flow;
for (int i = head[u]; i != -1; i = edge[i].nxt) {
int v = edge[i].v;
if (rk[v] != rk[u] + 1 || !edge[i].w)continue;
if (!tmpadd) { rk[v] = -1; continue; }
}
}

int ans;
void dinic() {
while (bfs())ans += dfs(st, inf);
}

int a[maxn];

bool check(int a, int b) {
if(a % 2 == 1 && b % 2 == 1)return 0;
if (gcd(a, b) != 1)return 0;
ll sum = a * a + b * b; int p = (int)sqrt(sum);
if (p*p != sum)return 0;
return 1;
}

int main()
{
//ios::sync_with_stdio(0);
rdint(n);int sum = 0;
for (int i = 1; i <= n; i++)rdint(a[i]), sum += a[i];
st = n + 1; ed = st + 1;
for (int i = 1; i <= n; i++) {
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= i; j++) {
if (check(a[i], a[j])) {