QOJ.ac

QOJ

Limite de temps : 3.0 s Limite de mémoire : 256 MB Points totaux : 100

#12948. 最大公约数

Statistiques

给定一个包含 $n$ 个数字的序列 $A$,定义 $f(lo, hi)$(其中 $1 \le lo \le hi \le n$)为序列中从 $A_{lo}$ 到 $A_{hi}$(包含两端)所有数字的最大公约数。注意 $lo$ 和 $hi$ 是下标,而非列表中的元素。给定一个数组,考虑所有可能的 $lo$ 和 $hi$ 取值,问 $f(lo, hi)$ 共有多少个不同的值?

输入包含多组测试数据。每组测试数据的第一行包含一个整数 $n$ ($1 \le n \le 100,000$),表示序列的长度。接下来的 $n$ 行,每行包含一个整数 $a$ ($1 \le a \le 100$),按顺序给出序列中的数字。输入以一行包含单个 $0$ 的数据结束。

对于每组测试数据,输出一个整数,表示对于该输入序列,$f(lo, hi)$ 可能取到的不同值的数量。不要输出任何空格,也不要在不同答案之间打印空行。

样例

输入格式 1

2
4
6
3
3
6
8
0

输出格式 1

3
5

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.