-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7de0186
commit 64485a9
Showing
2 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import java.util.Scanner; | ||
public class Main{ | ||
public static void main(String[] args){ | ||
Scanner sc = new Scanner(System.in); | ||
int num = sc.nextInt(); | ||
while(num!=0){ | ||
int count = 0; | ||
int out = num; | ||
num = 0; | ||
while(num!=out){ | ||
num = out; | ||
out = next(num); | ||
count++; | ||
} | ||
System.out.println(count-1); | ||
count = 0; | ||
num = sc.nextInt(); | ||
} | ||
} | ||
|
||
public static int next(int num){ | ||
System.out.println(" "+num); | ||
int count =0; | ||
while(num>0){ | ||
int c = num%10; | ||
System.out.println(" C: "+c); | ||
count+=c*c*c; | ||
num/=10; | ||
} | ||
System.out.println(" "+count); | ||
return count; | ||
} | ||
} | ||
|
||
class number{ | ||
int[] num; | ||
int times; | ||
number(){ | ||
times = 0; | ||
num = new int[4]; | ||
for(int i=0;i<4;i++) | ||
num[i] = 0; | ||
} | ||
|
||
public number(int init){ | ||
num = new int[4]; | ||
times = 0; | ||
for(int i = 0;i<4;i++) | ||
num[i] = 0; | ||
int count = 0; | ||
while(init>0){ | ||
num[count] = init%10; | ||
count++; | ||
init/=10; | ||
} | ||
} | ||
|
||
public int next(){ | ||
int sum = 0; | ||
for(int i = 0;i<4;i++) | ||
sum += num[i]*num[i]*num[i]; | ||
return sum; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Compile the source filei | ||
echo "Compiling..." | ||
javac DivideBy3.java | ||
|
||
echo "------------------ Test Starting ----------------------" | ||
echo "java DivideBy3" | ||
|
||
START=`date +%s%N`; | ||
echo "Result:" `java DivideBy3` | ||
END=`date +%s%N`; | ||
time=$((END-START)) | ||
time=`expr $time / 1000000` | ||
echo "Elapsed time:" $time "ms" | ||
echo "---------------------- Test Ends ----------------------" | ||
|
||
|
||
|