FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Algorithm/codeForces/codeForces_13A_Numbers.cpp at master · shellteo/Algorithm · GitHub
shellteo
/
Algorithm
Public
forked from
OneCodeMonkey/Algorithm
Notifications
You must be signed in to change notification settings
Fork
0
Star
1
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Algorithm
/
codeForces
/
codeForces_13A_Numbers.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
44 lines (39 loc) · 710 Bytes
Breadcrumbs
Algorithm
/
codeForces
/
codeForces_13A_Numbers.cpp
Copy path
File metadata and controls
44 lines (39 loc) · 710 Bytes
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
/*
*
* 思路:没有优化的部分,只需依次算出 2,n-1 进制下的各位加和。注意最后表示分数的时候要做简化,先求出最大公约数。
* AC:
* Time:62 ms Memory:0 KB
*
*/
#
include
<
stdio.h
>
#
include
<
map
>
#
include
<
utility
>
#
include
<
math.h
>
using
namespace
std
;
int
gcd
(
int
a,
int
b)
{
if
(a <=
0
|| b <=
0
)
//
exception
return
0
;
if
(a < b)
std::swap
(a,b);
if
(a % b ==
0
)
return
b;
else
return
gcd
(b, a % b);
}
int
main
()
{
int
n, m =
0
, sum =
0
;
scanf
(
"
%d
"
, &n);
for
(
int
i =
2
; i < n; i++) {
m = n;
while
(m) {
sum += m % i;
m /= i;
}
}
int
z =
gcd
(sum, n -
2
);
int
x = sum / z;
int
y = (n -
2
) / z;
printf
(
"
%d/%d
"
, x, y);
return
0
;
}
Back
|
FazBrowse Home
|
New Git URL