Skip to content

Commit 59ac4a7

Browse files
committed
1020
1 parent 69fc943 commit 59ac4a7

File tree

3 files changed

+68
-0
lines changed

3 files changed

+68
-0
lines changed

.idea/modules.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

BOJ/silver/BOJ1476/BOJ1476.iml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module type="JAVA_MODULE" version="4">
3+
<component name="NewModuleRootManager" inherit-compiler-output="true">
4+
<exclude-output />
5+
<content url="file://$MODULE_DIR$">
6+
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
7+
</content>
8+
<orderEntry type="inheritedJdk" />
9+
<orderEntry type="sourceFolder" forTests="false" />
10+
</component>
11+
</module>

BOJ/silver/BOJ1476/src/Main.java

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import java.io.BufferedReader;
2+
import java.io.IOException;
3+
import java.io.InputStreamReader;
4+
import java.util.StringTokenizer;
5+
6+
public class Main {
7+
public static void main(String[] args) throws IOException {
8+
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
9+
StringTokenizer st =new StringTokenizer(br.readLine());
10+
int E=Integer.parseInt(st.nextToken());
11+
int S=Integer.parseInt(st.nextToken());
12+
int M=Integer.parseInt(st.nextToken());
13+
14+
int E_MAX=15;
15+
int S_MAX=28;
16+
int M_MAX=19;
17+
//E와 S의 최대공약수를 구한다.
18+
int gcdTmp=GCD(E_MAX,S_MAX);
19+
//E와 S의 최소공배수를구한다.
20+
int lcmTmp=(E_MAX*S_MAX)/gcdTmp;
21+
//구한 최대공약수와 M의 최대공약수를 구한다.
22+
int gcd=GCD(lcmTmp,M_MAX);
23+
//구한 최소공배수와 M의 최소공배수를 구한다.
24+
int lcd=(lcmTmp*M_MAX)/gcd;
25+
26+
27+
int cacYear=E;
28+
while (cacYear<=lcd){
29+
if((cacYear-S)%S_MAX==0 &&(cacYear-M)%M_MAX==0 ){
30+
break;
31+
}
32+
cacYear+=E_MAX;
33+
}
34+
System.out.println(cacYear);
35+
36+
37+
38+
39+
40+
41+
42+
43+
44+
}
45+
46+
47+
private static int GCD(int a, int b) {
48+
int now= a%b;
49+
if(now==0){
50+
return b;
51+
}else{
52+
return GCD(b,now);
53+
}
54+
}
55+
56+
}

0 commit comments

Comments
 (0)