提出 #71387069


ソースコード 拡げる

#include <stdio.h>
#include <inttypes.h>

int N;
int a[312345];

int main(void) {
	int i;
	int64_t ans = 0;
	int start = 0;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d", &a[i]) != 1) return 1;
	}
	for (i = 1; i <= N; i++) { /* 最後の要素の次を番兵として用いる */
		if (a[start] != a[i]) {
			int nelems = i - start;
			ans += (int64_t)nelems * (nelems - 1) / 2;
			start = i;
		}
	}
	printf("%" PRId64 "\n", ans);
	return 0;
}

/*

a_i <= a_j で a_i が a_j の倍数なのは、a_i = a_j のときのみ

*/

提出情報

提出日時
問題 A - 倍数ペア
ユーザ mikecat
言語 C (gcc 12.2.0)
得点 100
コード長 592 Byte
結果 AC
実行時間 27 ms
メモリ 2904 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 100 / 100
結果
AC × 3
AC × 15
セット名 テストケース
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_rnd_00.txt, 01_rnd_01.txt, 01_rnd_02.txt, 01_rnd_03.txt, 01_rnd_04.txt, 01_rnd_05.txt, 01_rnd_06.txt, 02_same_00.txt, 02_same_01.txt, 02_same_02.txt, 03_prime_00.txt, 03_prime_01.txt
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 0 ms 1624 KiB
00_sample_01.txt AC 0 ms 1616 KiB
00_sample_02.txt AC 0 ms 1732 KiB
01_rnd_00.txt AC 22 ms 2592 KiB
01_rnd_01.txt AC 4 ms 1864 KiB
01_rnd_02.txt AC 20 ms 2584 KiB
01_rnd_03.txt AC 10 ms 2156 KiB
01_rnd_04.txt AC 24 ms 2800 KiB
01_rnd_05.txt AC 26 ms 2880 KiB
01_rnd_06.txt AC 27 ms 2804 KiB
02_same_00.txt AC 0 ms 1724 KiB
02_same_01.txt AC 22 ms 2884 KiB
02_same_02.txt AC 20 ms 2896 KiB
03_prime_00.txt AC 23 ms 2808 KiB
03_prime_01.txt AC 24 ms 2904 KiB