import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringBuffer sb = new StringBuffer("");
BigInteger arr[] = new BigInteger[1501];
BigInteger sum[] = new BigInteger[1501];
arr[0] = BigInteger.ZERO;
sum[0]=BigInteger.ZERO;
arr[1] = BigInteger.ZERO;
sum[1]=BigInteger.ZERO;
arr[2] = BigInteger.ONE;
sum[2]=BigInteger.ONE;
arr[3] = BigInteger.valueOf(2);
sum[3]= BigInteger.valueOf(3);
for (int i = 4; i < 1501; i++) {
arr[i] = arr[i - 2].add(arr[i - 1]);
sum[i]=sum[i-1].add(arr[i]);
}
int i=1;
while (true) {
int m = Integer.parseInt(br.readLine());
if (m == 0) {
break;
}
BigInteger two=BigInteger.valueOf(2);
sb.append("Set ").append(i).append(":\n");
if((arr[m].mod(two)).compareTo(BigInteger.ZERO)==0){
sb.append(sum[m-1].add(arr[m].divide(two))).append("\n");
}else{
sb.append(sum[m-1].add((arr[m].add(BigInteger.ONE)).divide(two))).append("\n");
}
i++;
}
System.out.print(sb);
}
}
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringBuffer sb = new StringBuffer("");
BigInteger arr[] = new BigInteger[1501];
BigInteger sum[] = new BigInteger[1501];
arr[0] = BigInteger.ZERO;
sum[0]=BigInteger.ZERO;
arr[1] = BigInteger.ZERO;
sum[1]=BigInteger.ZERO;
arr[2] = BigInteger.ONE;
sum[2]=BigInteger.ONE;
arr[3] = BigInteger.valueOf(2);
sum[3]= BigInteger.valueOf(3);
for (int i = 4; i < 1501; i++) {
arr[i] = arr[i - 2].add(arr[i - 1]);
sum[i]=sum[i-1].add(arr[i]);
}
int i=1;
while (true) {
int m = Integer.parseInt(br.readLine());
if (m == 0) {
break;
}
BigInteger two=BigInteger.valueOf(2);
sb.append("Set ").append(i).append(":\n");
if((arr[m].mod(two)).compareTo(BigInteger.ZERO)==0){
sb.append(sum[m-1].add(arr[m].divide(two))).append("\n");
}else{
sb.append(sum[m-1].add((arr[m].add(BigInteger.ONE)).divide(two))).append("\n");
}
i++;
}
System.out.print(sb);
}
}
No comments:
Post a Comment