#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<int> ch[100005];
int col[100005];
int n, m;
bool impossible()
{
bool had = false;
for (int i = 0;i < n;i++) if (ch[i].size() >= 2)
{
if (had) return false;
had = true;
}
return true;
}
bool dfs(int at)
{
for (int u: ch[at])
{
int c = !col[at];
if (col[u] == 2)
{
col[u] = c;
if (!dfs(u)) return false;
} else if (col[u] != c)
return false;
}
return true;
}
bool bipartite()
{
for (int i = 0;i < n;i++) col[i] = 2;
col[0] = 0;
return dfs(0);
}
int main()
{
scanf("%d%d", &n, &m);
for (int i = 0;i < m;i++)
{
int a, b; scanf("%d%d", &a, &b);
--a, --b;
ch[a].push_back(b);
ch[b].push_back(a);
}
if (impossible()) printf("0\n");
else if (!bipartite()) printf("%lld\n", 1ll*n*(n-1)/2-m);
else
{
ll a = 0, b = 0;
for (int i = 0;i < n;i++) (col[i]?a:b)++;
printf("%lld\n", a*b-m);
}
return 0;
}
./Main.cpp: In function ‘int main()’:
./Main.cpp:45:23: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d", &n, &m);
^
./Main.cpp:48:34: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
int a, b; scanf("%d%d", &a, &b);
^