Submission #5395049


Source Code Expand

Copy
#include <iostream>
#include <string>
#include <algorithm>
#include <map>

using namespace std;
map <long long, int> b;
int main()
{
	int n,a[200005],i,k,l,m,p,t=0;
	cin >> n >> k;
	for(i=0; i<n; i++)
		cin >> a[i];
	if(k!=1)
	{
	for(i=0; i<n; i++)
	{
		p=k;
		while(p!=a[i])
		{
			l=max(p,a[i]);
			m=min(p,a[i]);
			p=l-m;
			a[i]=m;
		}
		b[p]++;
	}
	for(i=2; i<k; i++)
	{
		if(k%i==0)
		{
			for(int j=k/i; j<k; j+=k/i)
			t+=b[i]*b[j];
		}
	}
	t=t/2;
	t+=b[k]*(n-b[k])+b[k]*(b[k]-1)/2;
	cout <<t;
    }
    else 
    {
    	cout << n*(n-1)/2;
	}
}

Submission Info

Submission Time
Task C - ロト2
User hurel
Language C++14 (GCC 5.4.1)
Score 0
Code Size 598 Byte
Status
Exec Time 2107 ms
Memory 237696 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 00_example_01.txt, 00_example_02.txt, 00_example_03.txt
All 0 / 400 00_example_01.txt, 00_example_02.txt, 00_example_03.txt, 10_random_01.txt, 10_random_02.txt, 10_random_03.txt, 10_random_04.txt, 10_random_05.txt, 20_max_01.txt, 20_max_02.txt, 20_max_03.txt, 20_max_04.txt, 20_max_05.txt, 30_overflow_01.txt, 30_overflow_02.txt, 40_dmax_01.txt, 40_dmax_02.txt, 40_dmax_03.txt, 50_prime_01.txt, 50_prime_02.txt, 50_prime_03.txt, 60_prime_pow_01.txt, 60_prime_pow_02.txt, 60_prime_pow_03.txt, 70_one_01.txt
Case Name Status Exec Time Memory
00_example_01.txt 1 ms 256 KB
00_example_02.txt 1 ms 256 KB
00_example_03.txt 1 ms 256 KB
10_random_01.txt
10_random_02.txt 946 ms 184064 KB
10_random_03.txt 32 ms 7168 KB
10_random_04.txt 1297 ms 237696 KB
10_random_05.txt
20_max_01.txt
20_max_02.txt
20_max_03.txt
20_max_04.txt
20_max_05.txt
30_overflow_01.txt
30_overflow_02.txt
40_dmax_01.txt
40_dmax_02.txt
40_dmax_03.txt
50_prime_01.txt
50_prime_02.txt
50_prime_03.txt
60_prime_pow_01.txt
60_prime_pow_02.txt
60_prime_pow_03.txt
70_one_01.txt 77 ms 1024 KB