FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Competitive-Programming/ASimpleProblem.cpp at master · KevinMathewT/Competitive-Programming · GitHub
KevinMathewT
/
Competitive-Programming
Public
Notifications
You must be signed in to change notification settings
Fork
3
Star
3
Code
Issues
0
Pull requests
1
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Competitive-Programming
/
ASimpleProblem.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
74 lines (60 loc) · 1.18 KB
Breadcrumbs
Competitive-Programming
/
ASimpleProblem.cpp
Copy path
File metadata and controls
74 lines (60 loc) · 1.18 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
69
70
71
72
73
74
#
include
<
bits/stdc++.h
>
using
namespace
std
;
typedef
long
long
ll;
//
Author - Kevin Mathew
//
Birla Institute of Technology, Mesra
ll size =
1e3
+
100
;
void
te
(){
ll n; cin >> n;
ll a[n];
for
(ll i=
0
;i<n;i++) cin >> a[i];
ll fact[size];
for
(ll i=
0
;i<size;i++) fact[i] = i;
for
(ll i=
2
;i*i<size;i++){
if
(fact[i] == i)
for
(ll j=i*i;j<size;j+=i)
fact[j] = i;
}
//
for(ll i=0;i<size;i++) cout << i << " " << fact[i] << "\n";
ll cum[n];
map<ll, ll> m;
for
(ll i=
0
;i<n;i++)
m[i] =
1
;
for
(ll i=
0
;i<n;i++){
ll count =
0
;
ll t = a[i];
while
(
true
){
if
(m.
find
(t) != m.
end
())
count++;
if
(fact[t] == t)
break
;
else
t /= fact[t];
cout << a[i] <<
"
"
<< t <<
"
\n
"
;
}
cum[i] = count;
cout << count <<
"
-
\n
"
;
}
cout <<
"
\n
"
;
for
(ll i=
1
;i<n;i++)
cum[i] = cum[i] + cum[i-
1
];
ll q;
cin >> q;
while
(q--){
ll l, r;
cin >> l >> r;
if
(l !=
0
)
cout << cum[r] - cum[l] <<
"
\n
"
;
else
cout << cum[r] <<
"
\n
"
;
}
}
int
main
()
{
freopen
(
"
input.txt
"
,
"
r
"
, stdin);
//
Comment
freopen
(
"
output.txt
"
,
"
w
"
, stdout);
//
this out.
ios::sync_with_stdio
(
false
);
//
Not
cin.
tie
(
NULL
);
//
this.
cout.
tie
(
0
);
//
or this.
te
();
return
0
;
}
Back
|
FazBrowse Home
|
New Git URL