QOJ.ac

QOJ

حد الوقت: 2.0 s حد الذاكرة: 1024 MB مجموع النقاط: 100

#8169. R-连通分量

الإحصائيات

对于一个正整数 $R$,定义以下无穷无向图中的连通分量个数为 $f(R)$。

  • 顶点集为 $\mathbb{Z}^2$。换句话说,对于任意整数对 $x, y$,都存在一个顶点 $(x, y)$。
  • 当且仅当 $|x_1 - x_2|^2 + |y_1 - y_2|^2 = R$ 时,顶点 $(x_1, y_1)$ 和 $(x_2, y_2)$ 之间存在一条边。

给定一个正整数 $R$,输出 $f(R)$。如果 $f(R)$ 为无穷大,则输出 inf。 给定 $T$ 组测试数据,请分别求解。

输入格式

输入通过标准输入按以下格式给出:

$T$ $case_1$ $case_2$ $\vdots$ $case_T$

每个 $case_i$ ($1 \le i \le T$) 按以下格式给出:

$R$

  • 输入中的所有值均为整数。
  • $1 \le T \le 100$
  • $1 \le R \le 10^9$

输出格式

对于每组测试数据,如果 $f(R)$ 是有限的,则输出 $f(R)$,否则输出 inf

样例

输入格式 1

3
1
2
3

输出格式 1

1
2
inf

说明

在第一个测试样例中,$R = 1$。边形成的结构如下图所示,最终得到一个连通分量。

在第二个测试样例中,$R = 2$。边形成的结构如下图所示,最终得到两个连通分量。

在第三个测试样例中,$R = 3$。该图中不存在任何边,因此连通分量的个数为无穷大。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.