Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- import java.io.*;
- public class S4_2018{
- static HashMap<Long, Long> set = new HashMap<Long, Long>();
- public static void main(String[] args) throws IOException {
- long N = readLong(); set.put((long) 1, (long) 1); println(rekt(N));
- exit();
- }
- public static long rekt(long n) {
- if(n == 1) return 1;
- if(set.containsKey(n)) return set.get(n);
- long ans = 0;
- // System.out.println(N);
- for(int i = 2; i<=Math.sqrt(n); i++) ans += rekt(n/i);
- int last = (int) Math.sqrt(n);
- for(int j = (int) Math.sqrt(n); j>=1; j--) {
- ans += (Math.floor(n/1.0/j)-last)*rekt(j);
- last = (int) Math.floor(n/1.0/j);
- }
- set.put(n, ans);
- return ans;
- }
- static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
- static StringTokenizer st;
- static PrintWriter pr = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
- static String next() throws IOException {
- while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine().trim());
- return st.nextToken();
- }
- static int readInt() throws IOException {return Integer.parseInt(next());}
- static long readLong() throws IOException {return Long.parseLong(next());}
- static String readLine() throws IOException {return br.readLine().trim();}
- static void print(Object o) {pr.print(o);}
- static void println(Object o) {pr.println(o);}
- static void println() {pr.println();}
- static void exit() throws IOException {
- br.close();
- pr.close();
- System.exit(0);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement