結果
| 問題 |
No.3240 Count 8 Included Numbers (Easy)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-08-22 21:06:00 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 58 ms / 2,000 ms |
| コード長 | 3,623 bytes |
| コンパイル時間 | 3,188 ms |
| コンパイル使用メモリ | 81,880 KB |
| 実行使用メモリ | 43,852 KB |
| 最終ジャッジ日時 | 2025-08-22 21:06:06 |
| 合計ジャッジ時間 | 5,515 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 16 |
ソースコード
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashSet;
import java.util.NoSuchElementException;
import java.util.Set;
class FastScanner {
private static FastScanner instance = null;
private final InputStream in = System.in;
private final byte[] buffer = new byte[1024];
private int ptr = 0;
private int buflen = 0;
private FastScanner() {} // 外部から new できないようにする
public static FastScanner getInstance() {
if (instance == null) {
instance = new FastScanner();
}
return instance;
}
private boolean hasNextByte() {
if (ptr < buflen) return true;
ptr = 0;
try {
buflen = in.read(buffer);
} catch (IOException e) {
e.printStackTrace();
}
return buflen > 0;
}
private int readByte() {
if (hasNextByte()) return buffer[ptr++];
else return -1;
}
private boolean isPrintableChar(int c) {
return 33 <= c && c <= 126;
}
public boolean hasNext() {
while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
return hasNextByte();
}
public String next() {
if (!hasNext()) throw new NoSuchElementException();
StringBuilder sb = new StringBuilder();
int b = readByte();
while (isPrintableChar(b)) {
sb.appendCodePoint(b);
b = readByte();
}
return sb.toString();
}
public long nextLong() {
if (!hasNext()) throw new NoSuchElementException();
long n = 0;
boolean minus = false;
int b = readByte();
if (b == '-') {
minus = true;
b = readByte();
}
while (b >= '0' && b <= '9') {
n = n * 10 + (b - '0');
b = readByte();
}
return minus ? -n : n;
}
public int nextInt() {
return (int) nextLong();
}
public long[] nextLongs(int n) {
long[] a = new long[n];
for (int i = 0; i < n; ++i) {
a[i] = nextLong();
}
return a;
}
public int[] nextInts(int n) {
int[] a = new int[n];
for (int i = 0; i < n; ++i) {
a[i] = nextInt();
}
return a;
}
}
class MyPrintWriter extends PrintWriter {
public MyPrintWriter(PrintStream out) {
super(out);
}
public void print(long[] a) {
print(a, " ");
}
public void print(int[] a) {
print(a, " ");
}
public void print(int[] a, String separator) {
for (int i = 0; i < a.length; ++i) {
super.print(a[i]+(i==a.length-1?"\n":separator));
}
}
public void print(long[] a, String separator) {
for (int i = 0; i < a.length; ++i) {
super.print(a[i]+(i==a.length-1?"\n":separator));
}
}
public void printlnYesNo(boolean flag) {
println(flag?"Yes":"No");
}
}
class Main implements Runnable { // Runnableを実装する
public static void main(String[] args) {
new Thread(null, new Main(), "", 1024 * 1024 * 1024).start(); // 1024MBスタックを確保して実行
}
public void run() {
FastScanner sc = FastScanner.getInstance();
MyPrintWriter pw = new MyPrintWriter(System.out);
int N=sc.nextInt();
int ans=0;
for(int i=1;i<=N;++i) {
boolean ok=false;
int a=i;
while(a>0) {
ok|=a%10==8;
a/=10;
}
if(ok)++ans;
}
System.out.println(ans);
pw.close();
}
static void tr(Object...objects) {System.out.println(Arrays.deepToString(objects));}
}