Guest User

Untitled

a guest
Jan 18th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <cstdio>
  4. #include <cstdlib>
  5. #include <cmath>
  6.  
  7. using namespace std;
  8.  
  9.  
  10. double f(double x){
  11. return x*x*x - 3*x*x + 9*x - 8;
  12. }
  13.  
  14. //惹かれ合う二者の運命
  15. void TheFateOfTwoPeopleWhoAreAttracted(double somethingWhoIsTheRootOfTheWorld, double thoseWhoDoNotKnowImpurityYet){
  16. //生命、宇宙、そして万物についての究極の疑問の答え
  17. int answerToTheUltimateQuestionAboutLifeUniverseAndAllThings = 42;
  18.  
  19. while(answerToTheUltimateQuestionAboutLifeUniverseAndAllThings){
  20. //かつて世界の根源だったもの
  21. double whatWasTheRootOfTheWorld = somethingWhoIsTheRootOfTheWorld;
  22. //新たな決意
  23. double newDetermination = (somethingWhoIsTheRootOfTheWorld*f(thoseWhoDoNotKnowImpurityYet) - thoseWhoDoNotKnowImpurityYet*f(somethingWhoIsTheRootOfTheWorld))
  24. / (f(thoseWhoDoNotKnowImpurityYet)-f(somethingWhoIsTheRootOfTheWorld));
  25.  
  26. //もしも新たな決意が世界の根源となるなら世界の根源の変革の時、まだ穢れを知らぬなら知らぬままに。
  27. if(f(newDetermination) > 0){
  28. thoseWhoDoNotKnowImpurityYet = newDetermination;
  29. }
  30. else if(f(newDetermination) < 0){
  31. somethingWhoIsTheRootOfTheWorld = newDetermination;
  32. }
  33. else{
  34. //節子それ近似解とちがう、厳密解や
  35. cout << "x = " << newDetermination << endl;
  36. return;
  37. }
  38. //世界の根源の変革が収束に向かうなら、ラグナロクの始まりが訪れる。
  39. if(fabs(whatWasTheRootOfTheWorld - somethingWhoIsTheRootOfTheWorld) < 0.00001){
  40. //全てを終わらせる時
  41. break;
  42. }
  43. }
  44.  
  45. //この世の解
  46. cout << somethingWhoIsTheRootOfTheWorld << " <= x <= " << thoseWhoDoNotKnowImpurityYet << endl;
  47. return;
  48. }
  49.  
  50. int main(void){
  51. //要ははさみうち法
  52. TheFateOfTwoPeopleWhoAreAttracted(0, 5);
  53. return 0;
  54. }
Add Comment
Please, Sign In to add comment