{"id":"50547778-a026-4712-9ecb-faede389f351","name":"Deleting Divisors","description":"https://codeforces.com/contest/1537/problem/D","inputFormat":"Check the link","outputFormat":"Check the link","constraints":"Check the link","sampleCode":{"cpp":{"code":""},"java":{"code":"import java.util.*;\r\nimport java.io.*;\r\n\r\npublic class Main {\r\n static StringBuilder sb;\r\n static dsu dsu;\r\n static long fact[];\r\n static int mod = (int) (1e9 + 7);\r\n\r\n static void solve() {\r\n\r\n }\r\n public static void main(String[] args) {\r\n sb = new StringBuilder();\r\n int test = i();\r\n while (test-- > 0) {\r\n solve();\r\n }\r\n System.out.println(sb);\r\n\r\n }\r\n\r\n /*\r\n * fact=new long[(int)1e6+10]; fact[0]=fact[1]=1; for(int i=2;i<fact.length;i++)\r\n * { fact[i]=((long)(i%mod)1L(long)(fact[i-1]%mod))%mod; }\r\n */\r\n//**************NCR%P******************\r\n static long ncr(int n, int r) {\r\n if (r > n)\r\n return (long) 0;\r\n\r\n long res = fact[n] % mod;\r\n // System.out.println(res);\r\n res = ((long) (res % mod) * (long) (p(fact[r], mod - 2) % mod)) % mod;\r\n res = ((long) (res % mod) * (long) (p(fact[n - r], mod - 2) % mod)) % mod;\r\n // System.out.println(res);\r\n return res;\r\n\r\n }\r\n\r\n static long p(long x, long y)// POWER FXN //\r\n {\r\n if (y == 0)\r\n return 1;\r\n\r\n long res = 1;\r\n while (y > 0) {\r\n if (y % 2 == 1) {\r\n res = (res * x) % mod;\r\n y--;\r\n }\r\n\r\n x = (x * x) % mod;\r\n y = y / 2;\r\n\r\n }\r\n return res;\r\n }\r\n\r\n//**************END******************\r\n\r\n // *************Disjoint set\r\n // union*********//\r\n static class dsu {\r\n int parent[];\r\n\r\n dsu(int n) {\r\n parent = new int[n];\r\n for (int i = 0; i < n; i++)\r\n parent[i] = -1;\r\n }\r\n\r\n int find(int a) {\r\n if (parent[a] < 0)\r\n return a;\r\n else {\r\n int x = find(parent[a]);\r\n parent[a] = x;\r\n return x;\r\n }\r\n }\r\n\r\n void merge(int a, int b) {\r\n a = find(a);\r\n b = find(b);\r\n if (a == b)\r\n return;\r\n parent[b] = a;\r\n }\r\n }\r\n\r\n//**************PRIME FACTORIZE **********************************//\r\n static TreeMap<Integer, Integer> prime(long n) {\r\n TreeMap<Integer, Integer> h = new TreeMap<>();\r\n long num = n;\r\n for (int i = 2; i <= Math.sqrt(num); i++) {\r\n if (n % i == 0) {\r\n int nt = 0;\r\n while (n % i == 0) {\r\n n = n / i;\r\n nt++;\r\n }\r\n h.put(i, nt);\r\n }\r\n }\r\n if (n != 1)\r\n h.put((int) n, 1);\r\n return h;\r\n\r\n }\r\n\r\n//****CLASS PAIR ************************************************\r\n static class Pair implements Comparable<Pair> {\r\n int x;\r\n long y;\r\n\r\n Pair(int x, long y) {\r\n this.x = x;\r\n this.y = y;\r\n }\r\n\r\n public int compareTo(Pair o) {\r\n return (int) (this.y - o.y);\r\n\r\n }\r\n\r\n }\r\n//****CLASS PAIR **************************************************\r\n\r\n static class InputReader {\r\n private InputStream stream;\r\n private byte[] buf = new byte[1024];\r\n private int curChar;\r\n private int numChars;\r\n private SpaceCharFilter filter;\r\n\r\n public InputReader(InputStream stream) {\r\n this.stream = stream;\r\n }\r\n\r\n public int read() {\r\n if (numChars == -1)\r\n throw new InputMismatchException();\r\n if (curChar >= numChars) {\r\n curChar = 0;\r\n try {\r\n numChars = stream.read(buf);\r\n } catch (IOException e) {\r\n throw new InputMismatchException();\r\n }\r\n if (numChars <= 0)\r\n return -1;\r\n }\r\n return buf[curChar++];\r\n }\r\n\r\n public int Int() {\r\n int c = read();\r\n while (isSpaceChar(c))\r\n c = read();\r\n int sgn = 1;\r\n if (c == ''-'') {\r\n sgn = -1;\r\n c = read();\r\n }\r\n int res = 0;\r\n do {\r\n if (c < ''0'' || c > ''9'')\r\n throw new InputMismatchException();\r\n res *= 10;\r\n res += c - ''0'';\r\n c = read();\r\n } while (!isSpaceChar(c));\r\n return res * sgn;\r\n }\r\n\r\n public String String() {\r\n int c = read();\r\n while (isSpaceChar(c))\r\n c = read();\r\n StringBuilder res = new StringBuilder();\r\n do {\r\n res.appendCodePoint(c);\r\n c = read();\r\n } while (!isSpaceChar(c));\r\n return res.toString();\r\n }\r\n\r\n public boolean isSpaceChar(int c) {\r\n if (filter != null)\r\n return filter.isSpaceChar(c);\r\n return c == '' '' || c == ''\\n'' || c == ''\\r'' || c == ''\\t'' || c == -1;\r\n }\r\n\r\n public String next() {\r\n return String();\r\n }\r\n\r\n public interface SpaceCharFilter {\r\n public boolean isSpaceChar(int ch);\r\n }\r\n }\r\n\r\n static class OutputWriter {\r\n private final PrintWriter writer;\r\n\r\n public OutputWriter(OutputStream outputStream) {\r\n writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));\r\n }\r\n\r\n public OutputWriter(Writer writer) {\r\n this.writer = new PrintWriter(writer);\r\n }\r\n\r\n public void print(Object... objects) {\r\n for (int i = 0; i < objects.length; i++) {\r\n if (i != 0)\r\n writer.print('' '');\r\n writer.print(objects[i]);\r\n }\r\n }\r\n\r\n public void printLine(Object... objects) {\r\n print(objects);\r\n writer.println();\r\n }\r\n\r\n public void close() {\r\n writer.close();\r\n }\r\n\r\n public void flush() {\r\n writer.flush();\r\n }\r\n }\r\n\r\n static InputReader in = new InputReader(System.in);\r\n static OutputWriter out = new OutputWriter(System.out);\r\n\r\n public static long[] sort(long[] a2) {\r\n int n = a2.length;\r\n ArrayList<Long> l = new ArrayList<>();\r\n for (long i : a2)\r\n l.add(i);\r\n Collections.sort(l);\r\n for (int i = 0; i < l.size(); i++)\r\n a2[i] = l.get(i);\r\n return a2;\r\n }\r\n\r\n public static char[] sort(char[] a2) {\r\n int n = a2.length;\r\n ArrayList<Character> l = new ArrayList<>();\r\n for (char i : a2)\r\n l.add(i);\r\n Collections.sort(l);\r\n for (int i = 0; i < l.size(); i++)\r\n a2[i] = l.get(i);\r\n return a2;\r\n }\r\n\r\n public static long pow(long x, long y) {\r\n long res = 1;\r\n while (y > 0) {\r\n if (y % 2 != 0) {\r\n res = (res * x);// % modulus;\r\n y--;\r\n\r\n }\r\n x = (x * x);// % modulus;\r\n y = y / 2;\r\n }\r\n return res;\r\n }\r\n\r\n//GCD___+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\r\n public static long gcd(long x, long y) {\r\n if (x == 0)\r\n return y;\r\n else\r\n return gcd(y % x, x);\r\n }\r\n // ******LOWEST COMMON MULTIPLE\r\n // *********************************************\r\n\r\n public static long lcm(long x, long y) {\r\n return (x * (y / gcd(x, y)));\r\n }\r\n\r\n//INPUT PATTERN********************************************************\r\n public static int i() {\r\n return in.Int();\r\n }\r\n\r\n public static long l() {\r\n String s = in.String();\r\n return Long.parseLong(s);\r\n }\r\n\r\n public static String s() {\r\n return in.String();\r\n }\r\n\r\n public static int[] readArrayi(int n) {\r\n int A[] = new int[n];\r\n for (int i = 0; i < n; i++) {\r\n A[i] = i();\r\n }\r\n return A;\r\n }\r\n\r\n public static long[] readArray(long n) {\r\n long A[] = new long[(int) n];\r\n for (int i = 0; i < n; i++) {\r\n A[i] = l();\r\n }\r\n return A;\r\n }\r\n\r\n}"},"ruby":{"code":""},"python":{"code":""},"javascript":{"code":""}},"points":10,"difficulty":"medium","sampleInput":"Check the link","sampleOutput":"Check the link","questionVideo":"","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"1191e2be-22c8-444b-988f-201dc78b143e","name":"Game Theory For Experts","slug":"game-theory-for-experts-930","type":0},{"id":"0998f30a-29e2-4ecc-9b55-8f05baff7c97","name":"Deleting Divisors","slug":"deleting-divisors","type":1}],"next":{"id":"0d8668cb-743f-46d1-94b2-8922f08c0b92","name":"Two Pile With Grundy Number","type":1,"slug":"two-pile-with-grundy-number"},"prev":{"id":"829c7664-a55b-43f9-b3b2-28979b10a9d1","name":"Grundy Number","type":1,"slug":"grundy-number"}}}

Deleting Divisors

https://codeforces.com/contest/1537/problem/D

{"id":"50547778-a026-4712-9ecb-faede389f351","name":"Deleting Divisors","description":"https://codeforces.com/contest/1537/problem/D","inputFormat":"Check the link","outputFormat":"Check the link","constraints":"Check the link","sampleCode":{"cpp":{"code":""},"java":{"code":"import java.util.*;\r\nimport java.io.*;\r\n\r\npublic class Main {\r\n static StringBuilder sb;\r\n static dsu dsu;\r\n static long fact[];\r\n static int mod = (int) (1e9 + 7);\r\n\r\n static void solve() {\r\n\r\n }\r\n public static void main(String[] args) {\r\n sb = new StringBuilder();\r\n int test = i();\r\n while (test-- > 0) {\r\n solve();\r\n }\r\n System.out.println(sb);\r\n\r\n }\r\n\r\n /*\r\n * fact=new long[(int)1e6+10]; fact[0]=fact[1]=1; for(int i=2;i<fact.length;i++)\r\n * { fact[i]=((long)(i%mod)1L(long)(fact[i-1]%mod))%mod; }\r\n */\r\n//**************NCR%P******************\r\n static long ncr(int n, int r) {\r\n if (r > n)\r\n return (long) 0;\r\n\r\n long res = fact[n] % mod;\r\n // System.out.println(res);\r\n res = ((long) (res % mod) * (long) (p(fact[r], mod - 2) % mod)) % mod;\r\n res = ((long) (res % mod) * (long) (p(fact[n - r], mod - 2) % mod)) % mod;\r\n // System.out.println(res);\r\n return res;\r\n\r\n }\r\n\r\n static long p(long x, long y)// POWER FXN //\r\n {\r\n if (y == 0)\r\n return 1;\r\n\r\n long res = 1;\r\n while (y > 0) {\r\n if (y % 2 == 1) {\r\n res = (res * x) % mod;\r\n y--;\r\n }\r\n\r\n x = (x * x) % mod;\r\n y = y / 2;\r\n\r\n }\r\n return res;\r\n }\r\n\r\n//**************END******************\r\n\r\n // *************Disjoint set\r\n // union*********//\r\n static class dsu {\r\n int parent[];\r\n\r\n dsu(int n) {\r\n parent = new int[n];\r\n for (int i = 0; i < n; i++)\r\n parent[i] = -1;\r\n }\r\n\r\n int find(int a) {\r\n if (parent[a] < 0)\r\n return a;\r\n else {\r\n int x = find(parent[a]);\r\n parent[a] = x;\r\n return x;\r\n }\r\n }\r\n\r\n void merge(int a, int b) {\r\n a = find(a);\r\n b = find(b);\r\n if (a == b)\r\n return;\r\n parent[b] = a;\r\n }\r\n }\r\n\r\n//**************PRIME FACTORIZE **********************************//\r\n static TreeMap<Integer, Integer> prime(long n) {\r\n TreeMap<Integer, Integer> h = new TreeMap<>();\r\n long num = n;\r\n for (int i = 2; i <= Math.sqrt(num); i++) {\r\n if (n % i == 0) {\r\n int nt = 0;\r\n while (n % i == 0) {\r\n n = n / i;\r\n nt++;\r\n }\r\n h.put(i, nt);\r\n }\r\n }\r\n if (n != 1)\r\n h.put((int) n, 1);\r\n return h;\r\n\r\n }\r\n\r\n//****CLASS PAIR ************************************************\r\n static class Pair implements Comparable<Pair> {\r\n int x;\r\n long y;\r\n\r\n Pair(int x, long y) {\r\n this.x = x;\r\n this.y = y;\r\n }\r\n\r\n public int compareTo(Pair o) {\r\n return (int) (this.y - o.y);\r\n\r\n }\r\n\r\n }\r\n//****CLASS PAIR **************************************************\r\n\r\n static class InputReader {\r\n private InputStream stream;\r\n private byte[] buf = new byte[1024];\r\n private int curChar;\r\n private int numChars;\r\n private SpaceCharFilter filter;\r\n\r\n public InputReader(InputStream stream) {\r\n this.stream = stream;\r\n }\r\n\r\n public int read() {\r\n if (numChars == -1)\r\n throw new InputMismatchException();\r\n if (curChar >= numChars) {\r\n curChar = 0;\r\n try {\r\n numChars = stream.read(buf);\r\n } catch (IOException e) {\r\n throw new InputMismatchException();\r\n }\r\n if (numChars <= 0)\r\n return -1;\r\n }\r\n return buf[curChar++];\r\n }\r\n\r\n public int Int() {\r\n int c = read();\r\n while (isSpaceChar(c))\r\n c = read();\r\n int sgn = 1;\r\n if (c == ''-'') {\r\n sgn = -1;\r\n c = read();\r\n }\r\n int res = 0;\r\n do {\r\n if (c < ''0'' || c > ''9'')\r\n throw new InputMismatchException();\r\n res *= 10;\r\n res += c - ''0'';\r\n c = read();\r\n } while (!isSpaceChar(c));\r\n return res * sgn;\r\n }\r\n\r\n public String String() {\r\n int c = read();\r\n while (isSpaceChar(c))\r\n c = read();\r\n StringBuilder res = new StringBuilder();\r\n do {\r\n res.appendCodePoint(c);\r\n c = read();\r\n } while (!isSpaceChar(c));\r\n return res.toString();\r\n }\r\n\r\n public boolean isSpaceChar(int c) {\r\n if (filter != null)\r\n return filter.isSpaceChar(c);\r\n return c == '' '' || c == ''\\n'' || c == ''\\r'' || c == ''\\t'' || c == -1;\r\n }\r\n\r\n public String next() {\r\n return String();\r\n }\r\n\r\n public interface SpaceCharFilter {\r\n public boolean isSpaceChar(int ch);\r\n }\r\n }\r\n\r\n static class OutputWriter {\r\n private final PrintWriter writer;\r\n\r\n public OutputWriter(OutputStream outputStream) {\r\n writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));\r\n }\r\n\r\n public OutputWriter(Writer writer) {\r\n this.writer = new PrintWriter(writer);\r\n }\r\n\r\n public void print(Object... objects) {\r\n for (int i = 0; i < objects.length; i++) {\r\n if (i != 0)\r\n writer.print('' '');\r\n writer.print(objects[i]);\r\n }\r\n }\r\n\r\n public void printLine(Object... objects) {\r\n print(objects);\r\n writer.println();\r\n }\r\n\r\n public void close() {\r\n writer.close();\r\n }\r\n\r\n public void flush() {\r\n writer.flush();\r\n }\r\n }\r\n\r\n static InputReader in = new InputReader(System.in);\r\n static OutputWriter out = new OutputWriter(System.out);\r\n\r\n public static long[] sort(long[] a2) {\r\n int n = a2.length;\r\n ArrayList<Long> l = new ArrayList<>();\r\n for (long i : a2)\r\n l.add(i);\r\n Collections.sort(l);\r\n for (int i = 0; i < l.size(); i++)\r\n a2[i] = l.get(i);\r\n return a2;\r\n }\r\n\r\n public static char[] sort(char[] a2) {\r\n int n = a2.length;\r\n ArrayList<Character> l = new ArrayList<>();\r\n for (char i : a2)\r\n l.add(i);\r\n Collections.sort(l);\r\n for (int i = 0; i < l.size(); i++)\r\n a2[i] = l.get(i);\r\n return a2;\r\n }\r\n\r\n public static long pow(long x, long y) {\r\n long res = 1;\r\n while (y > 0) {\r\n if (y % 2 != 0) {\r\n res = (res * x);// % modulus;\r\n y--;\r\n\r\n }\r\n x = (x * x);// % modulus;\r\n y = y / 2;\r\n }\r\n return res;\r\n }\r\n\r\n//GCD___+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\r\n public static long gcd(long x, long y) {\r\n if (x == 0)\r\n return y;\r\n else\r\n return gcd(y % x, x);\r\n }\r\n // ******LOWEST COMMON MULTIPLE\r\n // *********************************************\r\n\r\n public static long lcm(long x, long y) {\r\n return (x * (y / gcd(x, y)));\r\n }\r\n\r\n//INPUT PATTERN********************************************************\r\n public static int i() {\r\n return in.Int();\r\n }\r\n\r\n public static long l() {\r\n String s = in.String();\r\n return Long.parseLong(s);\r\n }\r\n\r\n public static String s() {\r\n return in.String();\r\n }\r\n\r\n public static int[] readArrayi(int n) {\r\n int A[] = new int[n];\r\n for (int i = 0; i < n; i++) {\r\n A[i] = i();\r\n }\r\n return A;\r\n }\r\n\r\n public static long[] readArray(long n) {\r\n long A[] = new long[(int) n];\r\n for (int i = 0; i < n; i++) {\r\n A[i] = l();\r\n }\r\n return A;\r\n }\r\n\r\n}"},"ruby":{"code":""},"python":{"code":""},"javascript":{"code":""}},"points":10,"difficulty":"medium","sampleInput":"Check the link","sampleOutput":"Check the link","questionVideo":"","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"1191e2be-22c8-444b-988f-201dc78b143e","name":"Game Theory For Experts","slug":"game-theory-for-experts-930","type":0},{"id":"0998f30a-29e2-4ecc-9b55-8f05baff7c97","name":"Deleting Divisors","slug":"deleting-divisors","type":1}],"next":{"id":"0d8668cb-743f-46d1-94b2-8922f08c0b92","name":"Two Pile With Grundy Number","type":1,"slug":"two-pile-with-grundy-number"},"prev":{"id":"829c7664-a55b-43f9-b3b2-28979b10a9d1","name":"Grundy Number","type":1,"slug":"grundy-number"}}}
plane

Editor


Loading...

Deleting Divisors

medium

https://codeforces.com/contest/1537/problem/D

Constraints

Check the link

Format

Input

Check the link

Output

Check the link

Example

Sample Input

Check the link

Sample Output

Check the link

Discussions

Show Discussion

Related Resources

related resources

Turning Off Zen Mode