fork download
  1. import java.util.Random;
  2.  
  3. public class Main {
  4.  
  5. public static void main(String[] args) {
  6. final Random random = new Random();
  7. double t = 0;
  8. double t1 = 6953;
  9. int cnt = 0;
  10. int cnt2 = 0;
  11. System.out.println("New temp: " + (int) t1);
  12. System.out.println("Real \tIndicate \tDelta");
  13. while (cnt2 < 11) {
  14. cnt++;
  15. t = (t + t1) / 2;
  16. System.out.print((int) t1 + "\t");
  17. System.out.printf("%.3f \t", t);
  18. System.out.printf("%.3f", (t1 - t));
  19. System.out.println();
  20. if (Math.abs(t1 - t) < 0.01) {
  21. System.out.println("Delta<0.01, total cicles:" + cnt);
  22. cnt = 0;
  23. if (cnt2 == 10)
  24. break;
  25. t1 = random.nextInt(10000);
  26. System.out.println();
  27. System.out.println("New temp: " + (int) t1);
  28. System.out.println("Real \tIndicate \tDelta");
  29. cnt2++;
  30. }
  31. }
  32.  
  33. }
  34.  
  35. }
  36.  
Success #stdin #stdout 0.08s 711680KB
stdin
Standard input is empty
stdout
New temp: 6953
Real 	Indicate 	Delta
6953	3476.500 	3476.500
6953	5214.750 	1738.250
6953	6083.875 	869.125
6953	6518.438 	434.563
6953	6735.719 	217.281
6953	6844.359 	108.641
6953	6898.680 	54.320
6953	6925.840 	27.160
6953	6939.420 	13.580
6953	6946.210 	6.790
6953	6949.605 	3.395
6953	6951.302 	1.698
6953	6952.151 	0.849
6953	6952.576 	0.424
6953	6952.788 	0.212
6953	6952.894 	0.106
6953	6952.947 	0.053
6953	6952.973 	0.027
6953	6952.987 	0.013
6953	6952.993 	0.007
Delta<0.01, total cicles:20

New temp: 6220
Real 	Indicate 	Delta
6220	6586.497 	-366.497
6220	6403.248 	-183.248
6220	6311.624 	-91.624
6220	6265.812 	-45.812
6220	6242.906 	-22.906
6220	6231.453 	-11.453
6220	6225.727 	-5.727
6220	6222.863 	-2.863
6220	6221.432 	-1.432
6220	6220.716 	-0.716
6220	6220.358 	-0.358
6220	6220.179 	-0.179
6220	6220.089 	-0.089
6220	6220.045 	-0.045
6220	6220.022 	-0.022
6220	6220.011 	-0.011
6220	6220.006 	-0.006
Delta<0.01, total cicles:17

New temp: 5174
Real 	Indicate 	Delta
5174	5697.003 	-523.003
5174	5435.501 	-261.501
5174	5304.751 	-130.751
5174	5239.375 	-65.375
5174	5206.688 	-32.688
5174	5190.344 	-16.344
5174	5182.172 	-8.172
5174	5178.086 	-4.086
5174	5176.043 	-2.043
5174	5175.021 	-1.021
5174	5174.511 	-0.511
5174	5174.255 	-0.255
5174	5174.128 	-0.128
5174	5174.064 	-0.064
5174	5174.032 	-0.032
5174	5174.016 	-0.016
5174	5174.008 	-0.008
Delta<0.01, total cicles:17

New temp: 6557
Real 	Indicate 	Delta
6557	5865.504 	691.496
6557	6211.252 	345.748
6557	6384.126 	172.874
6557	6470.563 	86.437
6557	6513.781 	43.219
6557	6535.391 	21.609
6557	6546.195 	10.805
6557	6551.598 	5.402
6557	6554.299 	2.701
6557	6555.649 	1.351
6557	6556.325 	0.675
6557	6556.662 	0.338
6557	6556.831 	0.169
6557	6556.916 	0.084
6557	6556.958 	0.042
6557	6556.979 	0.021
6557	6556.989 	0.011
6557	6556.995 	0.005
Delta<0.01, total cicles:18

New temp: 7097
Real 	Indicate 	Delta
7097	6826.997 	270.003
7097	6961.999 	135.001
7097	7029.499 	67.501
7097	7063.250 	33.750
7097	7080.125 	16.875
7097	7088.562 	8.438
7097	7092.781 	4.219
7097	7094.891 	2.109
7097	7095.945 	1.055
7097	7096.473 	0.527
7097	7096.736 	0.264
7097	7096.868 	0.132
7097	7096.934 	0.066
7097	7096.967 	0.033
7097	7096.984 	0.016
7097	7096.992 	0.008
Delta<0.01, total cicles:16

New temp: 8490
Real 	Indicate 	Delta
8490	7793.496 	696.504
8490	8141.748 	348.252
8490	8315.874 	174.126
8490	8402.937 	87.063
8490	8446.468 	43.532
8490	8468.234 	21.766
8490	8479.117 	10.883
8490	8484.559 	5.441
8490	8487.279 	2.721
8490	8488.640 	1.360
8490	8489.320 	0.680
8490	8489.660 	0.340
8490	8489.830 	0.170
8490	8489.915 	0.085
8490	8489.957 	0.043
8490	8489.979 	0.021
8490	8489.989 	0.011
8490	8489.995 	0.005
Delta<0.01, total cicles:18

New temp: 9164
Real 	Indicate 	Delta
9164	8826.997 	337.003
9164	8995.499 	168.501
9164	9079.749 	84.251
9164	9121.875 	42.125
9164	9142.937 	21.063
9164	9153.469 	10.531
9164	9158.734 	5.266
9164	9161.367 	2.633
9164	9162.684 	1.316
9164	9163.342 	0.658
9164	9163.671 	0.329
9164	9163.835 	0.165
9164	9163.918 	0.082
9164	9163.959 	0.041
9164	9163.979 	0.021
9164	9163.990 	0.010
9164	9163.995 	0.005
Delta<0.01, total cicles:17

New temp: 2002
Real 	Indicate 	Delta
2002	5582.997 	-3580.997
2002	3792.499 	-1790.499
2002	2897.249 	-895.249
2002	2449.625 	-447.625
2002	2225.812 	-223.812
2002	2113.906 	-111.906
2002	2057.953 	-55.953
2002	2029.977 	-27.977
2002	2015.988 	-13.988
2002	2008.994 	-6.994
2002	2005.497 	-3.497
2002	2003.749 	-1.749
2002	2002.874 	-0.874
2002	2002.437 	-0.437
2002	2002.219 	-0.219
2002	2002.109 	-0.109
2002	2002.055 	-0.055
2002	2002.027 	-0.027
2002	2002.014 	-0.014
2002	2002.007 	-0.007
Delta<0.01, total cicles:20

New temp: 7556
Real 	Indicate 	Delta
7556	4779.003 	2776.997
7556	6167.502 	1388.498
7556	6861.751 	694.249
7556	7208.875 	347.125
7556	7382.438 	173.562
7556	7469.219 	86.781
7556	7512.609 	43.391
7556	7534.305 	21.695
7556	7545.152 	10.848
7556	7550.576 	5.424
7556	7553.288 	2.712
7556	7554.644 	1.356
7556	7555.322 	0.678
7556	7555.661 	0.339
7556	7555.831 	0.169
7556	7555.915 	0.085
7556	7555.958 	0.042
7556	7555.979 	0.021
7556	7555.989 	0.011
7556	7555.995 	0.005
Delta<0.01, total cicles:20

New temp: 967
Real 	Indicate 	Delta
967	4261.497 	-3294.497
967	2614.249 	-1647.249
967	1790.624 	-823.624
967	1378.812 	-411.812
967	1172.906 	-205.906
967	1069.953 	-102.953
967	1018.477 	-51.477
967	992.738 	-25.738
967	979.869 	-12.869
967	973.435 	-6.435
967	970.217 	-3.217
967	968.609 	-1.609
967	967.804 	-0.804
967	967.402 	-0.402
967	967.201 	-0.201
967	967.101 	-0.101
967	967.050 	-0.050
967	967.025 	-0.025
967	967.013 	-0.013
967	967.006 	-0.006
Delta<0.01, total cicles:20

New temp: 7023
Real 	Indicate 	Delta
7023	3995.003 	3027.997
7023	5509.002 	1513.998
7023	6266.001 	756.999
7023	6644.500 	378.500
7023	6833.750 	189.250
7023	6928.375 	94.625
7023	6975.688 	47.312
7023	6999.344 	23.656
7023	7011.172 	11.828
7023	7017.086 	5.914
7023	7020.043 	2.957
7023	7021.521 	1.479
7023	7022.261 	0.739
7023	7022.630 	0.370
7023	7022.815 	0.185
7023	7022.908 	0.092
7023	7022.954 	0.046
7023	7022.977 	0.023
7023	7022.988 	0.012
7023	7022.994 	0.006
Delta<0.01, total cicles:20