-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathArray_force.cpp
More file actions
41 lines (39 loc) · 795 Bytes
/
Array_force.cpp
File metadata and controls
41 lines (39 loc) · 795 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <bits/stdc++.h>
using namespace std;
int main()
{
cin.sync_with_stdio(false);
cin.tie(0);
int t;
cin >> t;
while (t--)
{
int a, b, n, mod;
int c;
cin >> a >> b >> n >> mod;
long long arr[mod+1];
int series[n];
for (auto i = 0; i < mod; i++)
{
arr[i] = 0;
}
arr[a]++;
arr[b]++;
series[0] = a;
series[1] = b;
for (auto i = 2; i < n; i++)
{
c = (a + b) % mod;
arr[c] = arr[c] + 1;
a = b;
b = c;
}
long long sum = 0;
for (auto i = 0; i < mod; i++)
{
sum += (long long)(arr[i] * arr[i]);
}
cout << sum << "\n";
}
return 0;
}