/ SeriousOJ /

Record Detail

Runtime Error


  
# Status Time Cost Memory Cost
#1 Runtime Error Exception in thread "main" java.lang.NoClassDefFoundError: Main$FastRead at Main.<clinit>(Main.java:9) Caused by: java.lang.ClassNotFoundException: Main$FastRead at java.net.URLClassLoader.findClass(URLClassLoader.java:387) at java.lang.ClassLoader.loadClass(ClassLoader.java:418) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352) at java.lang.ClassLoader.loadClass(ClassLoader.java:351) ... 1 more 65ms 14.57 MiB
#2 Runtime Error Exception in thread "main" java.lang.NoClassDefFoundError: Main$FastRead at Main.<clinit>(Main.java:9) Caused by: java.lang.ClassNotFoundException: Main$FastRead at java.net.URLClassLoader.findClass(URLClassLoader.java:387) at java.lang.ClassLoader.loadClass(ClassLoader.java:418) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352) at java.lang.ClassLoader.loadClass(ClassLoader.java:351) ... 1 more 65ms 14.48 MiB

Code



import java.util.*;
import java.io.*;

public class Main {
    // KILL SPEEDFORCES
    // KILL RATING
    static FastRead sc = new FastRead(System.in);
    static PrintWriter out = new PrintWriter(System.out);
    private static class FastRead {
        private final InputStream stream;private final byte[] buf = new byte[1<<18];private int curChar, numChars;public FastRead (InputStream stream) {this.stream = stream;}
        public FastRead (String file) throws IOException {this.stream = new FileInputStream (file);}
        void run() {try {PrintStream fs = new PrintStream("error.txt");System.setErr(fs);} catch (FileNotFoundException e) {e.printStackTrace();}} //error.txt handler
        public int cscan () throws IOException {
            if (curChar >= numChars) {curChar = 0;numChars = stream.read (buf);}if (numChars == -1) return numChars;return buf[curChar++];}
        public int nextInt () throws IOException {
            int c = cscan (), sgn = 1;while (space (c)) c = cscan ();if (c == '-') {sgn = -1;c = cscan ();}
            int res = 0;do {res = (res << 1) + (res << 3);res += c - '0';c = cscan ();} while (!space (c));return res * sgn;}
        public String nextString () throws IOException {
            int c = cscan ();while (space (c)) c = cscan ();StringBuilder res = new StringBuilder ();do {res.appendCodePoint (c);c = cscan ();} while (!space (c));
            return res.toString ();}
        public double nextDouble () throws IOException {
            int c = cscan (), sgn = 1;while (space (c)) c = cscan ();if (c == '-') {sgn = -1;c = cscan ();}double res = 0;
            while (!space (c) && c != '.') {if (c == 'e' || c == 'E') return res * exp(10, nextInt ()); res *= 10;res += c - '0';c = cscan ();}
            if (c == '.') {c = cscan ();double m = 1;while (!space (c)) {if (c == 'e' || c == 'E') return res * exp(10, nextInt ());m /= 10;res += (c - '0') * m;c = cscan ();}}
            return res * sgn;}
        public long nextLong () throws IOException {
            int c = cscan (), sgn = 1;while (space (c)) c = cscan ();if (c == '-') {sgn = -1;c = cscan ();}long res = 0;do {res = (res << 1) + (res << 3);res += c - '0';c = cscan ();}
            while (!space (c));return res * sgn;}
        public boolean space (int c) {return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;}
    }
    static final int mod = 998244353;
    static long mul(long a, long b) {return (a * b) % mod;}
    static long exp(long base, long exp) {if (exp == 0) return 1;long half = exp(base, exp / 2); if (exp % 2 == 0) return mul(half, half);return mul(half, mul(half, base));}
    static void debug(Object... o){if(o.length != 0) System.err.println(Arrays.deepToString(o));else System.err.println();}
    static long expMod(long base, long exp, long modulo){ // T.C: O(log exp)
        long res = 1; base = base % modulo;if (base == 0) return 0;while (exp > 0) {if ((exp & 1) != 0) res = (res * base) % modulo;exp = exp >> 1;base = (base * base) % modulo;}return res;}
    static long modInv(long a, long modulo){return expMod(a , modulo-2 , modulo);}
    static long mod_add(long a, long b, long modulo) {a = a % modulo; b = b % modulo; return (((a + b) % modulo) + modulo) % modulo;}
    static long mod_mult(long a, long b, long modulo) {a = a % modulo; b = b % modulo; return (((a * b) % modulo) + modulo) % modulo;}
    static long mod_sub(long a, long b, long modulo) {a = a % modulo; b = b % modulo; return (((a - b) % modulo) + modulo) % modulo;}
    static long mod_div(long a, long b, long modulo) {a = a % modulo; b = b % modulo; return (mod_mult(a, modInv(b, modulo), modulo) + modulo) % modulo;}
    static long[] factorials = new long[2_000_001];
    static long[] invFactorials = new long[2_000_001];
    static void preCompFacts() {
        powerUp = true;
        factorials[0] = invFactorials[0] = 1;
        for (int i = 1; i < factorials.length; i++)
            factorials[i] = mod_mult(factorials[i - 1], i,mod);
        invFactorials[factorials.length - 1] = modInv(factorials[factorials.length - 1],mod);
        for (int i = invFactorials.length - 2; i >= 0; i--)
            invFactorials[i] = mod_mult(invFactorials[i + 1], i + 1,mod);
    }
    static boolean powerUp = false;
    static long nCk(int n, int k) {
        if(!powerUp) preCompFacts();
        return mod_mult(factorials[n], mod_mult(invFactorials[k], invFactorials[n - k],mod),mod);
    }

    static int[] code;
    static boolean dfs(ArrayList<Integer>[] al ,int st,int e,StringBuilder ans,int p){
        if(st == e) {
            return true;
        }
        for(int v : al[st]){
            if(v == p) continue;
            boolean b = dfs(al , v , e,ans,st);
            if(b) {
                ans.append(v).append(" ");
                code[v] = -1;
                return true;
            }
        }
        return false;
    }
    static void doo(int v,int p,ArrayList<Integer>[]al,HashSet<Integer> hs){
        if(code[v] != -1) hs.add(v);
        for(int c : al[v]){
            if(c == p) continue;
            doo(c,v,al,hs);
        }
    }
    static void dfss(int end,ArrayList<Integer>[]al,ArrayList<HashSet<Integer>> sets){
        for(int v : al[end]){
            HashSet<Integer> hs = new HashSet<>();
            doo(v,end,al,hs);
            if(!hs.isEmpty()) sets.add(hs);
        }
    }
    public static void main(String[] args)throws IOException {
        int t=sc.nextInt();
        while(t-- > 0){
            int n=sc.nextInt();
            int x=sc.nextInt();
            int[] a = new int[n];
            int i;
            for(i=0;i<n;i++) {a[i]=sc.nextInt();}
            int q=sc.nextInt();
            ArrayList<int[]> al = new ArrayList<>();
            int cx = x;
            for(i=2;i<=100000;i++){
                int ct = 0;
                while (cx%i == 0) {
                    ++ct;
                    cx /= i;
                }
                if (ct > 0) al.add(new int[]{i, ct});
            }
            if(cx > 1) al.add(new int[]{cx,1});
            long[][] pp =new long[al.size()][n];
            for(i=0;i<al.size();i++){
                for(int j=0;j<n;j++){
                    int temp = a[j];
                    int ct = 0;
                    while (temp % al.get(i)[0] == 0){
                        ct++;
                        temp /= al.get(i)[0];
                    }
                    pp[i][j] = ct;
                }
            }

            for(i=0;i<al.size();i++) for(int j=1;j<n;j++) pp[i][j] += pp[i][j-1];

            while (q-- > 0){
                int l=sc.nextInt()-1;
                int r=sc.nextInt()-1;
                int ct = 0;
                for(i=0;i<al.size();i++){
                    long sum = pp[i][r] - (l-1>=0  ? pp[i][l-1]:0);
                    if(sum >= al.get(i)[1]) ++ct;
                }
                if(ct == al.size()) out.println("YES");
                else out.println("NO");
            }
            out.flush();
        }
        out.close();
    }
}

Information

Submit By
Type
Submission
Problem
P1128 Roy and Product
Language
Java 8 (OpenJDK 1.8.0_422)
Submit At
2025-03-14 17:07:18
Judged At
2025-03-14 17:07:31
Judged By
Score
0
Total Time
65ms
Peak Memory
14.57 MiB