Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission (s): 2228 Accepted Submission (s ): 1277 the Problem Description1 Heap has n stones, and the two take turns. the first accessors can fetch any number of entries for 1st times, but not all of them. in the future, the number of stones retrieved each time cannot exceed 2 times the number of stones obtained last time. Winner. the first accessor outputs "Second win ". the winner wins the output of "First win ". there are multiple Input groups. the 1st rows in each group are 2 <= n <2 ^ 31. n = 0 exit. the Output operator outputs "Second win ". the winner wins the output of "First win ". see Sample Output. sample input0000100000 Sample OutputSecond winSecond winFirst win SourceECJTU 2008 Autumn Contest Recommendlcy | We have carefully selected several similar problems for you: 2509 2512 1536 1907 1524
import java.io.InputStreamReader; import java.util.Scanner; public class Main{ public static void main(String[] args) { Scanner input=new Scanner(new InputStreamReader(System.in)); int n; while((n=input.nextInt())!=0){ if(n<4){ System.out.println("Second win"); continue; } long a=2; long b=3; long c=0; for(int i=1;;i++){ c=a+b; a=b; b=c; if(c>=n) break; } if(c==n){ System.out.println("Second win"); } else System.out.println("First win"); } } }