SlideShare ist ein Scribd-Unternehmen logo
1 von 3
Downloaden Sie, um offline zu lesen
1 //humanity is a very illusive quality 
2 
3 /* 
4 Name: 
5 OJ: 
6 Link: 
7 Algorithm: 
8 Type: 
9 Difficulty: 
10 Interest: 
11 Additional: 
12 */ 
13 #include<cstdio> 
14 #include<cstring> 
15 #include<cstdlib> 
16 #include<cctype> 
17 
18 #include<cmath> 
19 #include<iostream> 
20 #include<fstream> 
21 
22 #include<string> 
23 #include<vector> 
24 #include<queue> 
25 #include<map> 
26 #include<algorithm> 
27 #include<set> 
28 #include<sstream> 
29 #include<stack> 
30 #include <ctime> 
31 using namespace std; 
32 
33 class TimeLogger { 
34 clock_t st, nd; double elapsed; 
35 public: 
36 TimeLogger() { st = clock(); } 
37 ~TimeLogger() { 
38 nd = clock(); elapsed = (nd - st)/(double)CLOCKS_PER_SEC; 
39 printf("nYour program took %.3lf secondsn", elapsed); 
40 } 
41 }; 
42 
43 const int inf = (1<<28); 
44 const double pi = (2.0*acos(0.0)); 
45 const double eps = 1e-9; 
46 const double eps2 = 1e-12; // printf rounder 
47 const double sensitiveEPS = 1e-14;// depends on digits after . ex 7 
digit 
48 
49 typedef long long lli; 
50 //typedef __int64 lli; 
51 //typedef unsigned long long llu; 
52 //typedef unsigned __int64 llu; 
53 //typedef pair < int , int > pii; 
54 //typedef vector < int > vi; 
55 //typedef vector < string > vs; 
56 
57 #define isp2( a ) (!(a & (a-1))) 
58 #define CLR( a ) memset(a , 0 , sizeof (a)) 
59 #define SET( a , b) memset(a , b , sizeof (a)) 
60 #define SZ( a ) ((int)a.size()) 
61 #define all( a ) a.begin(),a.end() 
62 
63 
64 //#define _rep( i, a, b, x ) for( __typeof(b) i = ( a ); i <= ( b ); 
i += x )
65 #define _rep( i, a, b, x ) for( i = ( a ) ; i <= ( b ) ; i += x ) 
66 #define rep( i, n ) _rep( i, 0, n - 1, 1 ) 
67 #define _rrep( i, a, b, x ) for( i = (a) ; i >= (b) ; i -= x ) 
68 #define rrep( i, a, b) _rrep( i, a, b, 1) 
69 #define xrep( i, a, b) _rep( i, a, b, 1) 
70 
71 #define SD( a ) scanf("%d",&a) 
72 #define SL( a ) scanf("%lld",&a) 
73 #define SI( a ) scanf("%I64d",&a) 
74 #define SS( a ) scanf("%s",a) 
75 #define SF( a ) scanf("%lf",&a) 
76 
77 #define pb push_back 
78 #define ff first 
79 #define ss second 
80 ///Comparision macros 
81 #define _aEb(a,b) (fabs((a)-(b))<eps) 
82 #define _aGb(a,b) ((a)>(b)+eps) 
83 #define _aLb(a,b) ((a)+eps<(b)) 
84 #define _aLEb(a,b) (_aLb(a,b) || _aEb(a,b)) 
85 #define _aGEb(a,b) (_aGb(a,b) || _aEb(a,b)) 
86 #define _minf(a,b) ((a)+eps<(b)?(a):(b)) 
87 #define _maxf(a,b) ((a)+eps<(b)?(b):(a)) 
88 #define _sq(x) ((x)*(x)) 
89 
90 const int MX = 1000; 
91 struct RKFMY 
92 { 
93 double t[ MX + 10 ]; 
94 double y[ MX + 10 ]; 
95 double w[ MX + 10 ]; 
96 double ww[ MX + 10 ]; 
97 double h[ MX + 10 ]; 
98 double R[ MX + 10 ]; 
99 double a , b , alpha , hmax, hmin; 
100 double TOL; 
101 bool flag; 
102 
103 double k[7]; 
104 
105 double f( double T , double Y ) 
106 { 
107 return ( Y - T*T + 1 ); 
108 } 
109 void init() 
110 { 
111 hmax = .25; 
112 hmin = .01; 
113 a = 0.; 
114 b = 2.; 
115 alpha = .5; 
116 t[ 0 ] = a; 
117 w[ 0 ] = alpha; 
118 h[ 0 ] = hmax; 
119 flag = true; 
120 TOL = 1.e-5; 
121 } 
122 double runIt() 
123 { 
124 int i = 0,j; 
125 while( flag && i<200 ) 
126 { 
127 k[1] = h[i] * f( t[i] , w[i] ); 
128 k[2] = h[i] * f( t[i] + (1./4.) * h[i] , w[i] + (1./4.) * 
k[1] ); 
129 k[3] = h[i] * f( t[i] + (3./8.) * h[i] , w[i] + (3./32.)*
k[1] + (9/32.)*k[2] ); 
130 k[4] = h[i] * f( t[i] + (12./13.)*h[i] , w[i] + (1932./ 
2197.)*k[1] 
131 - (7200./2197)*k[2] + (7296./ 
2197)*k[3] ); 
132 k[5] = h[i] * f( t[i] + h[i] , w[i] + (439./ 
216.)*k[1] - 8.*k[2] 
133 + (3680./513)*k[3] - (845./ 
4104)*k[4] ) ; 
134 k[6] = h[i] * f( t[i] + .5*h[i] , w[i] - (8./27.)* 
k[1] + 2.*k[2] 
135 - (3544./2565.)*k[3] + (1859./ 
4104.)*k[4] - (11./40.)*k[5] ); 
136 i++; 
137 
138 R[i] = (1./h[i-1]) * fabs( (1./360.)*k[1] - (128./4275.)* 
k[3] - (2197./75240.)*k[4] 
139 + (1./50.)*k[5] 
+ (2./55.)*k[6] ); 
140 
141 if( _aLEb(R[i],TOL) ) 
142 { 
143 t[i] = t[i-1] + h[i-1]; 
144 w[i] = w[i-1] + (25./216.)*k[1] + (1408./2565.)*k[3] 
+ (2197./4104.)*k[4] - (1./5.)*k[5]; 
145 printf("%.12lf %.12lf %.12lf %.12lfn",t[i],w[i],h[ 
i-1],R[i]); 
146 } 
147 
148 double del = .84 * pow( double(TOL / R[i]) , double(1./4. 
) ); 
149 
150 if( _aLb( del , .1 ) ) h[i] = .1 *h[i-1]; 
151 else if ( _aGb( del , 4. ) ) h[i] = 4 *h[i-1]; 
152 else h[i] = del*h[i-1]; 
153 
154 if( _aGb( h[i] , hmax ) ) h[i] = hmax ; 
155 if( _aGb( t[i] , b ) ) flag = 0; 
156 else if( _aGb( t[i] + h[i] , b ) ) h[i] = b-t[i]; 
157 else if( _aLb( h[i] , hmin ) ) 
158 { 
159 flag = 0; 
160 printf("min h exceededn"); 
161 } 
162 } 
163 } 
164 
165 }; 
166 RKFMY rk; 
167 int main(void) 
168 { 
169 //freopen("in.txt","r",stdin); 
170 //freopen("out.txt","w",stdout); 
171 //TimeLogger tm; 
172 int i,j,k,kase=0; 
173 
174 rk.init(); 
175 rk.runIt(); 
176 
177 return 0; 
178 }

Weitere ähnliche Inhalte

Was ist angesagt?

Python 101 language features and functional programming
Python 101 language features and functional programmingPython 101 language features and functional programming
Python 101 language features and functional programmingLukasz Dynowski
 
ARM 7 LPC 2148 lecture
ARM 7 LPC 2148 lectureARM 7 LPC 2148 lecture
ARM 7 LPC 2148 lectureanishgoel
 
Perlで任意精度計算
Perlで任意精度計算Perlで任意精度計算
Perlで任意精度計算lestrrat
 
Geo distance search with my sql presentation
Geo distance search with my sql presentationGeo distance search with my sql presentation
Geo distance search with my sql presentationGSMboy
 
Copia de derivadas tablas
Copia de derivadas tablasCopia de derivadas tablas
Copia de derivadas tablasGeral Delgado
 
CRL 1.8 functions MrG 2011.0920 - sage
CRL 1.8 functions MrG 2011.0920  - sageCRL 1.8 functions MrG 2011.0920  - sage
CRL 1.8 functions MrG 2011.0920 - sageA Jorge Garcia
 
(Appendix_Codes) Game Programming Portfolio - Soobum Lee
(Appendix_Codes) Game Programming Portfolio - Soobum Lee(Appendix_Codes) Game Programming Portfolio - Soobum Lee
(Appendix_Codes) Game Programming Portfolio - Soobum LeeSOOBUM LEE
 
Elur niahc and trig
Elur niahc and trigElur niahc and trig
Elur niahc and trigShaun Wilson
 
Computer graphics programs in c++
Computer graphics programs in c++Computer graphics programs in c++
Computer graphics programs in c++Ankit Kumar
 

Was ist angesagt? (19)

Presentation1
Presentation1Presentation1
Presentation1
 
Python 101 language features and functional programming
Python 101 language features and functional programmingPython 101 language features and functional programming
Python 101 language features and functional programming
 
Mosaic plot in R.
Mosaic plot in R.Mosaic plot in R.
Mosaic plot in R.
 
Hw #2
Hw #2Hw #2
Hw #2
 
ARM 7 LPC 2148 lecture
ARM 7 LPC 2148 lectureARM 7 LPC 2148 lecture
ARM 7 LPC 2148 lecture
 
dplyr
dplyrdplyr
dplyr
 
Htdp27.key
Htdp27.keyHtdp27.key
Htdp27.key
 
Perlで任意精度計算
Perlで任意精度計算Perlで任意精度計算
Perlで任意精度計算
 
Sample document
Sample documentSample document
Sample document
 
Geo distance search with my sql presentation
Geo distance search with my sql presentationGeo distance search with my sql presentation
Geo distance search with my sql presentation
 
Copia de derivadas tablas
Copia de derivadas tablasCopia de derivadas tablas
Copia de derivadas tablas
 
CRL 1.8 functions MrG 2011.0920 - sage
CRL 1.8 functions MrG 2011.0920  - sageCRL 1.8 functions MrG 2011.0920  - sage
CRL 1.8 functions MrG 2011.0920 - sage
 
CRL 1.8 Functions
CRL 1.8 FunctionsCRL 1.8 Functions
CRL 1.8 Functions
 
Sheet 1
Sheet 1Sheet 1
Sheet 1
 
(Appendix_Codes) Game Programming Portfolio - Soobum Lee
(Appendix_Codes) Game Programming Portfolio - Soobum Lee(Appendix_Codes) Game Programming Portfolio - Soobum Lee
(Appendix_Codes) Game Programming Portfolio - Soobum Lee
 
Math 3-H6
Math 3-H6Math 3-H6
Math 3-H6
 
NVT MD
NVT MDNVT MD
NVT MD
 
Elur niahc and trig
Elur niahc and trigElur niahc and trig
Elur niahc and trig
 
Computer graphics programs in c++
Computer graphics programs in c++Computer graphics programs in c++
Computer graphics programs in c++
 

Andere mochten auch

почталет
почталетпочталет
почталетit-park
 
Survival of the Fittest: Integrating Social Media W/ Sales & Marketing
Survival of the Fittest: Integrating Social Media W/ Sales & MarketingSurvival of the Fittest: Integrating Social Media W/ Sales & Marketing
Survival of the Fittest: Integrating Social Media W/ Sales & MarketingPersonalHealthCloud
 
vb profile 150825
vb profile 150825vb profile 150825
vb profile 150825Vic Baxter
 
ARD Fire Company Leaflet for 2015
ARD Fire Company Leaflet for 2015ARD Fire Company Leaflet for 2015
ARD Fire Company Leaflet for 2015Allan Deans
 
"Охота на Работу: Как найти и договориться быстро"
"Охота на Работу: Как найти и договориться быстро""Охота на Работу: Как найти и договориться быстро"
"Охота на Работу: Как найти и договориться быстро"C.A.T. | Career Advancement Technologies
 
Performance lab company overview
Performance lab company overviewPerformance lab company overview
Performance lab company overviewGeorge Kovalov
 
Закон кармы
Закон кармыЗакон кармы
Закон кармыJTGroup
 
Chamblee amanda vis1
Chamblee amanda vis1Chamblee amanda vis1
Chamblee amanda vis1achambl3
 
Brunel Energy Company Presentation
Brunel Energy Company PresentationBrunel Energy Company Presentation
Brunel Energy Company Presentationbvdenberg
 
Chaturmas Address 2013
Chaturmas Address 2013Chaturmas Address 2013
Chaturmas Address 2013jainacharya
 

Andere mochten auch (14)

почталет
почталетпочталет
почталет
 
Stamparija dual mode kontakt-3
Stamparija dual mode kontakt-3Stamparija dual mode kontakt-3
Stamparija dual mode kontakt-3
 
Mkk d275
Mkk d275Mkk d275
Mkk d275
 
Smartsport
SmartsportSmartsport
Smartsport
 
Survival of the Fittest: Integrating Social Media W/ Sales & Marketing
Survival of the Fittest: Integrating Social Media W/ Sales & MarketingSurvival of the Fittest: Integrating Social Media W/ Sales & Marketing
Survival of the Fittest: Integrating Social Media W/ Sales & Marketing
 
vb profile 150825
vb profile 150825vb profile 150825
vb profile 150825
 
ARD Fire Company Leaflet for 2015
ARD Fire Company Leaflet for 2015ARD Fire Company Leaflet for 2015
ARD Fire Company Leaflet for 2015
 
"Охота на Работу: Как найти и договориться быстро"
"Охота на Работу: Как найти и договориться быстро""Охота на Работу: Как найти и договориться быстро"
"Охота на Работу: Как найти и договориться быстро"
 
Filter press
Filter pressFilter press
Filter press
 
Performance lab company overview
Performance lab company overviewPerformance lab company overview
Performance lab company overview
 
Закон кармы
Закон кармыЗакон кармы
Закон кармы
 
Chamblee amanda vis1
Chamblee amanda vis1Chamblee amanda vis1
Chamblee amanda vis1
 
Brunel Energy Company Presentation
Brunel Energy Company PresentationBrunel Energy Company Presentation
Brunel Energy Company Presentation
 
Chaturmas Address 2013
Chaturmas Address 2013Chaturmas Address 2013
Chaturmas Address 2013
 

Ähnlich wie Rkf

Erlang Introduction Bcberlin3
Erlang Introduction Bcberlin3Erlang Introduction Bcberlin3
Erlang Introduction Bcberlin3guesta3202
 
C Code and the Art of Obfuscation
C Code and the Art of ObfuscationC Code and the Art of Obfuscation
C Code and the Art of Obfuscationguest9006ab
 
Coscup2021-rust-toturial
Coscup2021-rust-toturialCoscup2021-rust-toturial
Coscup2021-rust-toturialWayne Tsai
 
Computer graphics lab manual
Computer graphics lab manualComputer graphics lab manual
Computer graphics lab manualUma mohan
 
include ltiostreamgt include ltstringgt include .pdf
include ltiostreamgt include ltstringgt include .pdfinclude ltiostreamgt include ltstringgt include .pdf
include ltiostreamgt include ltstringgt include .pdfcontact32
 
algorithm design file
algorithm design filealgorithm design file
algorithm design filesuraj kumar
 
Cocos2d Performance Tips
Cocos2d Performance TipsCocos2d Performance Tips
Cocos2d Performance TipsKeisuke Hata
 
Graphics programs
Graphics programsGraphics programs
Graphics programsNAVYA RAO
 
The International Journal of Engineering and Science (IJES)
The International Journal of Engineering and Science (IJES)The International Journal of Engineering and Science (IJES)
The International Journal of Engineering and Science (IJES)theijes
 
Assignment7.pdf
Assignment7.pdfAssignment7.pdf
Assignment7.pdfdash41
 
Grand centraldispatch
Grand centraldispatchGrand centraldispatch
Grand centraldispatchYuumi Yoshida
 
Microsoft Word Hw#1
Microsoft Word   Hw#1Microsoft Word   Hw#1
Microsoft Word Hw#1kkkseld
 
第13回数学カフェ「素数!!」二次会 LT資料「乱数!!」
第13回数学カフェ「素数!!」二次会 LT資料「乱数!!」第13回数学カフェ「素数!!」二次会 LT資料「乱数!!」
第13回数学カフェ「素数!!」二次会 LT資料「乱数!!」Ken'ichi Matsui
 
Numerical Method Assignment
Numerical Method AssignmentNumerical Method Assignment
Numerical Method Assignmentashikul akash
 
Junaid program assignment
Junaid program assignmentJunaid program assignment
Junaid program assignmentJunaid Ahmed
 

Ähnlich wie Rkf (20)

Erlang Introduction Bcberlin3
Erlang Introduction Bcberlin3Erlang Introduction Bcberlin3
Erlang Introduction Bcberlin3
 
Vcs16
Vcs16Vcs16
Vcs16
 
C Code and the Art of Obfuscation
C Code and the Art of ObfuscationC Code and the Art of Obfuscation
C Code and the Art of Obfuscation
 
Prelude to halide_public
Prelude to halide_publicPrelude to halide_public
Prelude to halide_public
 
Coscup2021-rust-toturial
Coscup2021-rust-toturialCoscup2021-rust-toturial
Coscup2021-rust-toturial
 
Computer graphics lab manual
Computer graphics lab manualComputer graphics lab manual
Computer graphics lab manual
 
include ltiostreamgt include ltstringgt include .pdf
include ltiostreamgt include ltstringgt include .pdfinclude ltiostreamgt include ltstringgt include .pdf
include ltiostreamgt include ltstringgt include .pdf
 
algorithm design file
algorithm design filealgorithm design file
algorithm design file
 
Cocos2d Performance Tips
Cocos2d Performance TipsCocos2d Performance Tips
Cocos2d Performance Tips
 
C arrays
C arraysC arrays
C arrays
 
Graphics programs
Graphics programsGraphics programs
Graphics programs
 
Mat fin
Mat finMat fin
Mat fin
 
The International Journal of Engineering and Science (IJES)
The International Journal of Engineering and Science (IJES)The International Journal of Engineering and Science (IJES)
The International Journal of Engineering and Science (IJES)
 
Assignment7.pdf
Assignment7.pdfAssignment7.pdf
Assignment7.pdf
 
C programs
C programsC programs
C programs
 
Grand centraldispatch
Grand centraldispatchGrand centraldispatch
Grand centraldispatch
 
Microsoft Word Hw#1
Microsoft Word   Hw#1Microsoft Word   Hw#1
Microsoft Word Hw#1
 
第13回数学カフェ「素数!!」二次会 LT資料「乱数!!」
第13回数学カフェ「素数!!」二次会 LT資料「乱数!!」第13回数学カフェ「素数!!」二次会 LT資料「乱数!!」
第13回数学カフェ「素数!!」二次会 LT資料「乱数!!」
 
Numerical Method Assignment
Numerical Method AssignmentNumerical Method Assignment
Numerical Method Assignment
 
Junaid program assignment
Junaid program assignmentJunaid program assignment
Junaid program assignment
 

Rkf

  • 1. 1 //humanity is a very illusive quality 2 3 /* 4 Name: 5 OJ: 6 Link: 7 Algorithm: 8 Type: 9 Difficulty: 10 Interest: 11 Additional: 12 */ 13 #include<cstdio> 14 #include<cstring> 15 #include<cstdlib> 16 #include<cctype> 17 18 #include<cmath> 19 #include<iostream> 20 #include<fstream> 21 22 #include<string> 23 #include<vector> 24 #include<queue> 25 #include<map> 26 #include<algorithm> 27 #include<set> 28 #include<sstream> 29 #include<stack> 30 #include <ctime> 31 using namespace std; 32 33 class TimeLogger { 34 clock_t st, nd; double elapsed; 35 public: 36 TimeLogger() { st = clock(); } 37 ~TimeLogger() { 38 nd = clock(); elapsed = (nd - st)/(double)CLOCKS_PER_SEC; 39 printf("nYour program took %.3lf secondsn", elapsed); 40 } 41 }; 42 43 const int inf = (1<<28); 44 const double pi = (2.0*acos(0.0)); 45 const double eps = 1e-9; 46 const double eps2 = 1e-12; // printf rounder 47 const double sensitiveEPS = 1e-14;// depends on digits after . ex 7 digit 48 49 typedef long long lli; 50 //typedef __int64 lli; 51 //typedef unsigned long long llu; 52 //typedef unsigned __int64 llu; 53 //typedef pair < int , int > pii; 54 //typedef vector < int > vi; 55 //typedef vector < string > vs; 56 57 #define isp2( a ) (!(a & (a-1))) 58 #define CLR( a ) memset(a , 0 , sizeof (a)) 59 #define SET( a , b) memset(a , b , sizeof (a)) 60 #define SZ( a ) ((int)a.size()) 61 #define all( a ) a.begin(),a.end() 62 63 64 //#define _rep( i, a, b, x ) for( __typeof(b) i = ( a ); i <= ( b ); i += x )
  • 2. 65 #define _rep( i, a, b, x ) for( i = ( a ) ; i <= ( b ) ; i += x ) 66 #define rep( i, n ) _rep( i, 0, n - 1, 1 ) 67 #define _rrep( i, a, b, x ) for( i = (a) ; i >= (b) ; i -= x ) 68 #define rrep( i, a, b) _rrep( i, a, b, 1) 69 #define xrep( i, a, b) _rep( i, a, b, 1) 70 71 #define SD( a ) scanf("%d",&a) 72 #define SL( a ) scanf("%lld",&a) 73 #define SI( a ) scanf("%I64d",&a) 74 #define SS( a ) scanf("%s",a) 75 #define SF( a ) scanf("%lf",&a) 76 77 #define pb push_back 78 #define ff first 79 #define ss second 80 ///Comparision macros 81 #define _aEb(a,b) (fabs((a)-(b))<eps) 82 #define _aGb(a,b) ((a)>(b)+eps) 83 #define _aLb(a,b) ((a)+eps<(b)) 84 #define _aLEb(a,b) (_aLb(a,b) || _aEb(a,b)) 85 #define _aGEb(a,b) (_aGb(a,b) || _aEb(a,b)) 86 #define _minf(a,b) ((a)+eps<(b)?(a):(b)) 87 #define _maxf(a,b) ((a)+eps<(b)?(b):(a)) 88 #define _sq(x) ((x)*(x)) 89 90 const int MX = 1000; 91 struct RKFMY 92 { 93 double t[ MX + 10 ]; 94 double y[ MX + 10 ]; 95 double w[ MX + 10 ]; 96 double ww[ MX + 10 ]; 97 double h[ MX + 10 ]; 98 double R[ MX + 10 ]; 99 double a , b , alpha , hmax, hmin; 100 double TOL; 101 bool flag; 102 103 double k[7]; 104 105 double f( double T , double Y ) 106 { 107 return ( Y - T*T + 1 ); 108 } 109 void init() 110 { 111 hmax = .25; 112 hmin = .01; 113 a = 0.; 114 b = 2.; 115 alpha = .5; 116 t[ 0 ] = a; 117 w[ 0 ] = alpha; 118 h[ 0 ] = hmax; 119 flag = true; 120 TOL = 1.e-5; 121 } 122 double runIt() 123 { 124 int i = 0,j; 125 while( flag && i<200 ) 126 { 127 k[1] = h[i] * f( t[i] , w[i] ); 128 k[2] = h[i] * f( t[i] + (1./4.) * h[i] , w[i] + (1./4.) * k[1] ); 129 k[3] = h[i] * f( t[i] + (3./8.) * h[i] , w[i] + (3./32.)*
  • 3. k[1] + (9/32.)*k[2] ); 130 k[4] = h[i] * f( t[i] + (12./13.)*h[i] , w[i] + (1932./ 2197.)*k[1] 131 - (7200./2197)*k[2] + (7296./ 2197)*k[3] ); 132 k[5] = h[i] * f( t[i] + h[i] , w[i] + (439./ 216.)*k[1] - 8.*k[2] 133 + (3680./513)*k[3] - (845./ 4104)*k[4] ) ; 134 k[6] = h[i] * f( t[i] + .5*h[i] , w[i] - (8./27.)* k[1] + 2.*k[2] 135 - (3544./2565.)*k[3] + (1859./ 4104.)*k[4] - (11./40.)*k[5] ); 136 i++; 137 138 R[i] = (1./h[i-1]) * fabs( (1./360.)*k[1] - (128./4275.)* k[3] - (2197./75240.)*k[4] 139 + (1./50.)*k[5] + (2./55.)*k[6] ); 140 141 if( _aLEb(R[i],TOL) ) 142 { 143 t[i] = t[i-1] + h[i-1]; 144 w[i] = w[i-1] + (25./216.)*k[1] + (1408./2565.)*k[3] + (2197./4104.)*k[4] - (1./5.)*k[5]; 145 printf("%.12lf %.12lf %.12lf %.12lfn",t[i],w[i],h[ i-1],R[i]); 146 } 147 148 double del = .84 * pow( double(TOL / R[i]) , double(1./4. ) ); 149 150 if( _aLb( del , .1 ) ) h[i] = .1 *h[i-1]; 151 else if ( _aGb( del , 4. ) ) h[i] = 4 *h[i-1]; 152 else h[i] = del*h[i-1]; 153 154 if( _aGb( h[i] , hmax ) ) h[i] = hmax ; 155 if( _aGb( t[i] , b ) ) flag = 0; 156 else if( _aGb( t[i] + h[i] , b ) ) h[i] = b-t[i]; 157 else if( _aLb( h[i] , hmin ) ) 158 { 159 flag = 0; 160 printf("min h exceededn"); 161 } 162 } 163 } 164 165 }; 166 RKFMY rk; 167 int main(void) 168 { 169 //freopen("in.txt","r",stdin); 170 //freopen("out.txt","w",stdout); 171 //TimeLogger tm; 172 int i,j,k,kase=0; 173 174 rk.init(); 175 rk.runIt(); 176 177 return 0; 178 }