File tree Expand file tree Collapse file tree 3 files changed +68
-0
lines changed
Expand file tree Collapse file tree 3 files changed +68
-0
lines changed Original file line number Diff line number Diff line change 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 >
Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments