-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1056 B.cpp
68 lines (59 loc) · 2.1 KB
/
1056 B.cpp
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/**
* Git >> Mohsin_Riad
░░░▄█████████████████▄
░░▐████▀▒██████████████▄
░▒██▀▒▒▒▒▒█████████▀█████
░▐██▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒████▌
░▐█▌▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒████▌
░░█▒▄▀▀▀▀▀▄▒▒▄▀▀▀▀▀▄▒▐███▌
░░░▐░░░▄▄░░▌▐░░░▄▄░░▌▐███▌
░▄▀▌░░░▀▀░░▌▐░░░▀▀░░▌▒▀▒█▌
░▌▒▀▄░░░░▄▀▒▒▀▄░░░▄▀▒▒▄▀▒▌
░▀▄▐▒▀▀▀▀▒▒▒▒▒▒▀▀▀▒▒▒▒▒▒█
░░░▀▌▒▄██▄▄▄▄████▄▒▒▒▒█▀
░░░░▄██████████████▒▒▐▌
░░░▀███▀▀████▀█████▀▒▌
░░░░░▌▒▒▒▄▒▒▒▄▒▒▒▒▒▒▐
░░░░░▌▒▒▒▒▀▀▀▒▒▒▒▒▒▒▐
**/
#include<bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mx 1000
#define endl "\n"
#define pb push_back
#define pob pop_back
typedef unsigned long long ll;
typedef double dd;
const int N = 1e5;
unsigned int fast_mod(unsigned int a, unsigned int b)
{
return a >= b ? a % b : a;
}
int main()
{
IOS
//freopen("input.txt", "r", stdin);
ll n, m, cnt = 0;
cin>>n>>m;
ll N = min(n,m);
for(int i=1; i<=N ;i++)
{
ll col = 0, row=n/m;
for(int j=1; j<=N ;j++)
{
ll temp = fast_mod((fast_mod(i,m)*fast_mod(i,m) + fast_mod(j,m)*fast_mod(j,m)),m);
if(temp == 0)
{
if(n%m >=1 && j<=n%m)
col++;
col += n/m;
}
}
if(n%m >=1 && i<=n%m)
row++;
cnt += row*col;
}
cout<<cnt<<endl;
return (0);
}