Let V (G) be the vertex set of a simple graph and E(G) its edge set. An Isomorphism from a simple graph G to a simple graph H is a bijection f : V (G) → V (H) such that uv ∈ E(G) if and only if f(u)f(v) ∈ E(H). We say, G is isomorphic to H if there is an isomorphism from G to H.
A complete graph is a simple graph whose vertices are pairwise adjacent: the unlabeled complete graph with n vertices is denoted Kn. For example, the following figure shows K5.
Finally, a decomposition of a graph is a list of subgraphs such that each edge appears in exactly one subgraph in the list.
Now, given a positive integer n, you are to determine if Kn decomposes into three airwiseisomorphic
subgraphs.
Input
First line of each test case consists of a positive integer n (n ≤ 100). The end of input will be indicated by a case where n = 0. This case should not be processed.
Output
For each test case, print ‘YES’ if Kn can be decomposed into three pairwise-isomorphic subgraphs and ‘NO’ otherwise.
Constraints
• n < 100
Sample Input
4
5
0
Sample Output
YES
NO
问题链接:UVA11393 Tri-Isomorphism
问题简述:(略)
问题分析:
给程序代码,暂时不解释。
程序说明:(略)
参考链接:(略)
题记:(略)
AC的C++语言程序如下:
/* UVA11393 Tri-Isomorphism */
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
while(~scanf("%d", &n) && n)
if(n == 1 || n % 3 == 2) puts("NO");
else puts("YES");
return 0;
}