#include "cielib.h" int main() { int d = podajD(); int k = podajK(); int r = podajR(); int rest, ri, le; int left[d], right[d], t[d]; for(int i=0; i<d; ++i) { left[i]=0; right[i]=r; t[i]=r/2; } while(right[0]-left[0]>2) { rest=(right[0]+left[0])%2; for(int i=0; i<d; ++i) { t[i] = left[i]; czyCieplo(t); t[i] = right[i]; if(czyCieplo(t)) { left[i] = (left[i]+right[i])/2; } else { right[i] = (left[i]+right[i])/2+rest; } t[i] = (left[i]+right[i])/2; } } for(int i=0; i<d; ++i) { ri=0; le=0; t[i] = left[i]; czyCieplo(t); t[i] = right[i]; if(czyCieplo(t)) { ri=1; } t[i] = left[i]; if(czyCieplo(t)) { le=1; } if(ri==1 && le==0) { t[i]=right[i]; } else if(ri==0 && le==1) { t[i]=left[i]; } else { t[i]=(left[i]+right[i])/2; } } znalazlem(t); }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | #include "cielib.h" int main() { int d = podajD(); int k = podajK(); int r = podajR(); int rest, ri, le; int left[d], right[d], t[d]; for(int i=0; i<d; ++i) { left[i]=0; right[i]=r; t[i]=r/2; } while(right[0]-left[0]>2) { rest=(right[0]+left[0])%2; for(int i=0; i<d; ++i) { t[i] = left[i]; czyCieplo(t); t[i] = right[i]; if(czyCieplo(t)) { left[i] = (left[i]+right[i])/2; } else { right[i] = (left[i]+right[i])/2+rest; } t[i] = (left[i]+right[i])/2; } } for(int i=0; i<d; ++i) { ri=0; le=0; t[i] = left[i]; czyCieplo(t); t[i] = right[i]; if(czyCieplo(t)) { ri=1; } t[i] = left[i]; if(czyCieplo(t)) { le=1; } if(ri==1 && le==0) { t[i]=right[i]; } else if(ri==0 && le==1) { t[i]=left[i]; } else { t[i]=(left[i]+right[i])/2; } } znalazlem(t); } |