結果

問題 No.537 ユーザーID
ユーザー Shun_PIShun_PI
提出日時 2017-06-30 22:48:45
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 2,497 bytes
コンパイル時間 3,199 ms
コンパイル使用メモリ 81,400 KB
実行使用メモリ 58,280 KB
最終ジャッジ日時 2024-04-15 06:48:36
合計ジャッジ時間 7,814 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
50,940 KB
testcase_01 AC 97 ms
51,444 KB
testcase_02 AC 84 ms
51,004 KB
testcase_03 AC 100 ms
52,752 KB
testcase_04 AC 85 ms
50,824 KB
testcase_05 AC 97 ms
51,164 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 84 ms
52,432 KB
testcase_10 AC 84 ms
51,032 KB
testcase_11 AC 97 ms
51,316 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 133 ms
53,100 KB
testcase_19 AC 123 ms
52,964 KB
testcase_20 AC 125 ms
52,952 KB
testcase_21 AC 125 ms
52,832 KB
testcase_22 AC 133 ms
53,092 KB
testcase_23 AC 149 ms
53,468 KB
testcase_24 AC 108 ms
52,140 KB
testcase_25 AC 158 ms
53,420 KB
testcase_26 AC 155 ms
53,408 KB
testcase_27 AC 200 ms
53,948 KB
testcase_28 AC 231 ms
58,280 KB
testcase_29 AC 252 ms
56,440 KB
testcase_30 AC 246 ms
56,864 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.IOException;
import java.io.InputStream;
import java.util.HashSet;
import java.util.NoSuchElementException;
 
public class Main {
	private static FastScanner sc = new FastScanner();
	
	public static void main(String[] args) {
		long N = sc.nextLong();
		
		HashSet<Long> set = new HashSet<>();
		for(long i=1; i*i<=N; i++) {
			if(N % i == 0) {
				set.add(i);
			}
		}
		
		HashSet<Long> set2 = new HashSet<>();
		set2.addAll(set);
		for(long num : set) {
			if(!set2.contains(N/num)) {
				set2.add(N/num);
			}
		}
		HashSet<String> sset = new HashSet<>();
		for(long num : set2) {
			String s = String.valueOf(num);
			String t = "";
			for(int i=0; i<s.length(); i++) {
				t += s.charAt(i);
			}
			for(int i=s.length()-1; i>=0; i--) {
				t += s.charAt(i);
			}
			if(!sset.contains(t)) {
				sset.add(t);
			}
		}
		
		System.out.println(sset.size());
	}
	
	static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if(ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch(IOException e) {
                    e.printStackTrace();
                }
                if(buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
        public boolean hasNext() { skipUnprintable(); 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() {
            return Long.parseLong(next());
        }
        public int nextInt(){
            return Integer.parseInt(next());
        }
        public double nextDouble(){
            return Double.parseDouble(next());
        }
    }
}
0