import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException {
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
StringBuffer sb = new StringBuffer("");
int i[] = new int[101];
int v[] = new int[101];
int x[] = new int[101];
int l[] = new int[101];
int c[] = new int[101];
for (int k = 1; k < 101; k++) {
if (k % 10 == 1 || k % 10 == 4 || k % 10 == 6 || k % 10 == 9) {
i[k]++;
} else if (k % 10 == 2 || k % 10 == 7) {
i[k] += 2;
} else if (k % 10 == 3 || k % 10 == 8) {
i[k] += 3;
}
i[k] += i[k - 1];
if (k % 10 == 4 || k % 10 == 5
|| k % 10 == 6 || k % 10 == 7 || k % 10 == 8) {
v[k]++;
}
v[k] += v[k - 1];
int dig = k / 10;
if(k%10==9)
x[k]++;
if (dig == 1 || dig == 4 || dig == 6 || dig == 9) {
x[k]++;
} else if (dig == 2 || dig == 7 ) {
x[k] += 2;
} else if (dig == 3 || dig == 8) {
x[k] += 3;
}
x[k] += x[k - 1];
if (dig>3 && dig<9) {
l[k]++;
}
l[k] += l[k - 1];
if(dig>8)
c[k]++;
c[k] += c[k - 1];
}
while (true) {
int temp = Integer.parseInt(br.readLine());
if (temp == 0) {
break;
}
sb.append(temp).append(": ").append(i[temp]).append(" i, ").append(v[temp]).append(" v, ")
.append(x[temp]).append(" x, ").append(l[temp]).append(" l, ")
.append(c[temp]).append(" c").append("\n");
}
System.out.print(sb);
}
}
No comments:
Post a Comment