<pre name="code" class="java">import java.math.BigInteger; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner cin = new Scanner(System.in); BigInteger[] f = new BigInteger[600]; f[0] = new BigInteger("1"); f[1] = new BigInteger("2"); for(int i = 2; i < 600; i ++) f[i] = f[i - 1].add(f[i - 2]); for(;;) { BigInteger a, b; int res = 0; a = cin.nextBigInteger(); b = cin.nextBigInteger(); if(a.compareTo(BigInteger.ZERO) == 0 && b.compareTo(BigInteger.ZERO) == 0) break; for(int i = 0; i < 600; i ++) if(f[i].compareTo(a) != -1 && f[i].compareTo(b) != 1) res ++; System.out.println(res); } } }
import java.math.BigInteger; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner cin = new Scanner(System.in); int t; t = cin.nextInt(); BigInteger a = new BigInteger("6"); BigInteger b = new BigInteger("18"); BigInteger c = new BigInteger("23"); BigInteger d = new BigInteger("24"); while(t-- > 0) { BigInteger N = cin.nextBigInteger(); BigInteger ans; ans = (N.multiply(N).multiply(N).multiply(N).subtract(a.multiply(N.multiply(N).multiply(N))).add(c.multiply(N.multiply(N))).subtract(b.multiply(N)).add(d)).divide(d); System.out.println(ans); } } }
import java.math.BigInteger; import java.util.Scanner; public class Main004 { public static void main(String[] args) { Scanner cin = new Scanner(System.in); BigInteger[] test = new BigInteger[1002]; test[1] = new BigInteger("2"); test[2] = new BigInteger("5"); test[3] = new BigInteger("13"); for (int i = 4; i <= 1000; i++) { test[i] = test[i - 1].add(test[i - 1]).add(test[i - 2]).add(test[i - 3]); } int n; while (cin.hasNext()) { n = cin.nextInt(); System.out.println(test[n]); } } }
import java.math.BigInteger; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner cin = new Scanner(System.in); BigInteger[][] f = new BigInteger[160][160]; for (int i = 0; i <=150; i++) { f[0][i] = new BigInteger("1"); } for (int i = 1; i <= 150; i++) { for (int j = 0; j <= 150; j++) { f[i][j] = new BigInteger("0"); } } for (int i = 1; i <= 150; i++) { for (int j = 1; j <= 150; j++) { for (int k =0; k < i; k++) { f[i][j] = f[i][j].add(f[k][j - 1].multiply(f[i - k -1][j])); } } } while (cin.hasNext()) { int n = cin.nextInt(), d = cin.nextInt(); if (n % 2 == 1) System.out.println("0"); else { n >>= 1; System.out.println(f[n][d].add(f[n][d - 1].negate())); } } } }
import java.math.BigInteger; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner cin = new Scanner(System.in); BigInteger[][] f = new BigInteger[30][30]; int[][] g = new int[30][30]; for(int i = 1; i <= 21; i++) { f[i][0] = new BigInteger("1"); g[i][0] = 1; for(int j = 1; i * j <= 21; j++) { f[i][j] = new BigInteger("1"); g[i][j] = i * g[i][j - 1]; g[i][j]++; for(int k = i; k >= 1; k--) { f[i][j] = f[i][j].multiply(f[i][j - 1].multiply(C(k * g[i][j - 1], g[i][j - 1]))); } } } while(cin.hasNext()) { int k = cin.nextInt(); int d = cin.nextInt(); System.out.println(f[k][d]); } } public static BigInteger C(int m, int n) { if(m - n < n) n = m - n; BigInteger res = new BigInteger("1"); for(int i = 1; i <= n; i++) res = res.multiply(BigInteger.valueOf(m - i + 1)).divide(BigInteger.valueOf(i)); return res; } }
import java.math.BigInteger; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner cin = new Scanner(System.in); BigInteger[] ans = new BigInteger[10009]; BigInteger d = new BigInteger("1"); ans[0] = new BigInteger("0"); int n, k = 0, ci = 1; for (int i = 1; i <= 10000; i++) { ans[i] = ans[i - 1].add(d); k++; if (k == ci) { k = 0; ci++; d = d.multiply(BigInteger.valueOf(2)); } } while (cin.hasNext()) { n = cin.nextInt(); System.out.println(ans[n]); } } }
#include <stdio.h> #include <algorithm> using namespace std; const int M = 700000; long long g[M]; int main() { int n, i; for (g[1] =1, g[2] = i = 3; i < M; i++) { g[i] = g[i - 1] + (lower_bound(g + 1, g + i, i) - g); } while (scanf("%d", &n), n) { printf("%d\n", lower_bound(g + 1, g + M, n) - g); } return 0; }
#include <stdio.h> #include <math.h> int main() { int T; scanf("%d", &T); while (T--) { int n, m; scanf("%d%d", &n, &m); int dis = m - n; if (!dis) { printf("0\n"); continue; } int s = (int)sqrt((double)dis); if (s * s == dis) s = 2 * s - 1; else if (s * (s + 1) < dis) s = 2 *s + 1; else s *= 2; printf("%d\n", s); } return 0; }
try { File test = new File("test.txt"); PrintStream out = new PrintStream(new FileOutputStream(test)); System.setOut(out); } catch(Exception e){}