青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

隨筆 - 87  文章 - 279  trackbacks - 0
<2025年11月>
2627282930311
2345678
9101112131415
16171819202122
23242526272829
30123456

潛心看書研究!

常用鏈接

留言簿(19)

隨筆分類(81)

文章分類(89)

相冊

ACM OJ

My friends

搜索

  •  

積分與排名

  • 積分 - 220431
  • 排名 - 118

最新評論

閱讀排行榜

評論排行榜

具體推導看書<<數值分析>>
code:

#include <iostream>
using namespace std;

const int MAXN = 100;

int n;
double x[MAXN], y[MAXN]; //下標從0..n
double alph[MAXN], beta[MAXN], a[MAXN], b[MAXN];
double h[MAXN];
double m[MAXN]; //各點的一階導數;

inline 
double sqr(double pa) {
    
return pa * pa;
}


double sunc(double p, int i) {
    
return (1 + 2 * (p - x[i]) / (x[i + 1- x[i])) * sqr((p - x[i + 1]) / (x[i + 1- x[i])) * y[i]
            
+ (1 + 2 * (p - x[i + 1]) / (x[i] - x[i + 1])) * sqr((p - x[i]) / (x[i + 1- x[i])) * y[i + 1]
            
+ (p - x[i]) * sqr((p - x[i + 1]) / (x[i] - x[i + 1])) * m[i]
            
+ (p - x[i + 1]) * sqr((p - x[i]) / (x[i + 1- x[i])) * m[i + 1];
}


int main() {
    
int i, j;
    
double xx;
    freopen(
"threeInsert.in""r", stdin);
    scanf(
"%d"&n);
    
for (i = 0; i <= n; i++) scanf("%lf%lf"&x[i], &y[i]);
    
// scanf("%lf%lf", &m[0], &m[n]);
    for (i = 0; i <= n - 1; i++) h[i] = x[i + 1- x[i];
    
//第一種邊界條件
    
//alph[0] = 0; alph[n] = 1; beta[0] = 2 * m[0]; beta[n] = 2 * m[n];
    
//第二種邊界條件
    alph[0= 1; alph[n] = 0; beta[0= 3 * (y[1- y[0]) / h[0]; beta[n] = 3 * (y[n] - y[n - 1/ h[n - 1]);
    
for (i = 1; i <= n - 1; i++{
        alph[i] 
= h[i - 1/ (h[i - 1+ h[i]);
        beta[i] 
= 3 * ((1 - alph[i]) * (y[i] - y[i - 1]) / h[i - 1+ alph[i] * (y[i + 1- y[i]) / h[i]);
    }

    a[
0= - alph[0/ 2; b[0= beta[0/ 2;
    
for (i = 1; i <= n; i++{
        a[i] 
= - alph[i] / (2 + (1 - alph[i]) * a[i - 1]);
        b[i] 
= (beta[i] - (1 - alph[i]) * b[i - 1]) / (2 + (1 - alph[i]) * a[i - 1]);
    }

    m[n 
+ 1= 0;
    
for (i = n; i >= 0; i--{
        m[i] 
= a[i] * m[i + 1+ b[i];
    }

    scanf(
"%lf"&xx);
    
for (i = 0; i < n; i++{
        
if (xx >= x[i] && xx <= x[i + 1]) break;
    }

    printf(
"%lf\n", sunc(xx, i));
    
return 0;
}
 
posted @ 2007-10-20 13:07 豪 閱讀(3601) | 評論 (4)編輯 收藏
Sailboat

Problem H: Sailboat

In the sailboat race, the contestant is requested to along with the prearrange path. Sailing ship's power comes from wind power and contestant's manpower. The wind power can completely used.

In a competition, the contestants are requested to along with a 1/4 circles with radius R, the sailboat will goto east from south. During this process, the wind direction is straight from west to the east with constant speed and power.

In order to maintain the travel direction, the athlete must adjust the sail to the vertical angle from movement direction in any time.

If the speed of sailboat is proportional to the power at movement direction, the proportional factor is k. Supposes the wind power is f, the athlete manpower is h, please given the time of sailboat from the beginning to the end.

Input

The first line of each case consists of 4 double number, that is radius of path: R, wind power: f,athlete manpower: h and proportional factor:k. In order to avoid the floating point error, you needn't output the answer directly. The next line is a integer n, the following n lines gives a double value which is candidate answer.

Output

For each candidate of each case, Only "Yes" or "No" should be printed. Output "Yes" if the relative error to your answer is less than 3%, otherwise "No". For example, if the model answer is 100, and the candidate is 98 or 102, you should output "Yes". Output one blank line between neighboring case

Sample Input

1.0 2.0 1.0 1.0
2
0.35
0.76

Sample Output

No
Yes

Problem Source: provided by skywind

#include <iostream>
#include 
<cmath>
using namespace std;

const int MAXN = 100;
const double PI = acos(-1.0);

double R, F, H, K, ans;
int n, cas;

double func(double x) {
    
return R / K / (H + F * cos(x));
}


double romberg(double a, double b, double EPS = 1e-6{
    
double t[MAXN][MAXN] = {0}, tmp;
    
int i, j, k, k2, m, m4;
    t[
0][0= (func(a) + func(b)) * (b - a) / 2;
    k 
= 1; k2 = 1;
    
while (1{
        tmp  
= 0;
        
for (i = 1; i <= k2; i++{
            tmp 
+= func(a + (2 * i - 1* (b - a) / (2 * k2));
        }

        t[
0][k] = (t[0][k - 1+ tmp * (b - a) / k2) / 2;
        
for (m = 1, m4=4; m <= k; m++, m4 *= 4{
            t[m][k 
- m] = (m4 * t[m - 1][k - m + 1- t[m - 1][k - m]) / (m4 - 1);
        }

        
if (fabs(t[k][0- t[k - 1][0]) < EPS) break;
        k
++; k2 *= 2;
    }

    
return t[k][0];
}


void solve() {
    
double tmp;
    scanf(
"%lf"&tmp);
    
if (fabs(tmp - ans) / ans < 0.03) printf("Yes\n");
    
else printf("No\n");
}


int main() {
    freopen(
"2457.in""r", stdin);
    
while (scanf("%lf%lf%lf%lf%d"&R, &F, &H, &K, &n) != EOF) {
        
if (cas) printf("\n");
        
else cas++;
        ans 
= romberg(0, PI/2);
        
while (n--{
            solve();
        }

    }

    
return 0;
}
posted @ 2007-10-20 01:02 豪 閱讀(704) | 評論 (0)編輯 收藏

Easy Problem

Time limit:1000 ms   Memory limit:65536 KB
Total Submit:1755 (462 users)   Accepted Submit:366 (332 users)

Description

In this problem, you're to calculate the distance between a point P(xp, yp, zp) and a segment (x1, y1, z1) − (x2, y2, z2), in a 3D space, i.e. the minimal distance from P to any point Q(xq, yq, zq) on the segment (a segment is part of a line).

Input

The first line contains a single integer T (1 ≤ T ≤ 1000), the number of test cases. Each test case is a single line containing 9 integers xp, yp, zp, x1, y1, z1, x2, y2, z2. These integers are all in [-1000,1000].

Output

For each test case, print the case number and the minimal distance, to two decimal places.

Sample Input

3
0 0 0 0 1 0 1 1 0
1 0 0 1 0 1 1 1 0
-1 -1 -1 0 1 0 -1 0 -1

Sample Output

Case 1: 1.00
Case 2: 0.71
Case 3: 1.00

Problem Source

The 32nd ACM-ICPC Beijing First Round Internet Contest

其實和二分差不多,劃個函數曲線出來,分三段,比劃一下就很容易理解了:)

#include <iostream>
#include 
<cmath>
using namespace std;

double dist(double l[], double r[]) {
    
return sqrt((l[0]-r[0])*(l[0]-r[0])+(l[1]-r[1])*(l[1]-r[1])+(l[2]-r[2])*(l[2]-r[2]));
}


int main() {
   
// freopen("1024.in", "r", stdin);
    int n, cas=0;
    
double l[3], r[3], p[3], p1[3], p2[3], d1, d2;
    scanf(
"%d"&n);
    
while (n--{
        scanf(
"%lf%lf%lf%lf%lf%lf%lf%lf%lf"&p[0], &p[1], &p[2], &l[0], &l[1], &l[2], &r[0], &r[1], &r[2]);
        
while (dist(l, r) > 1e-4{
            p1[
0= (l[0+ r[0]) / 2;
            p1[
1= (l[1+ r[1]) / 2;
            p1[
2= (l[2+ r[2]) / 2;
            p2[
0= (r[0+ p1[0]) / 2;
            p2[
1= (r[1+ p1[1]) / 2;
            p2[
2= (r[2+ p1[2]) / 2;
            d1 
= dist(p1, p); d2 = dist(p2, p);
            
if (d2 >= d1) {
                r[
0= p2[0]; r[1= p2[1]; r[2= p2[2];
            }
 else {
                l[
0= p1[0]; l[1= p1[1]; l[2= p1[2];
            }

        }

        printf(
"Case %d: %.2lf\n"++cas, dist(p,l));
    }

}

posted @ 2007-10-18 11:00 豪 閱讀(1216) | 評論 (0)編輯 收藏
昨晚去圖書館看了《計算機圖形學——OpenGL實現》關于Bresenham算法的另一種推導方式。
Bresenham最精妙之處在于通過方程變換,然后得到迭代方程,從而消除了浮點運算。

下面簡單寫寫自己對中點法推導的理解:

記:W = bx - ax, H = by - ay
         所以 (ax, ay)和(bx, by)的理想直線為:
         -W*(y-ay) + H*(x-ax) = 0

記:函數 f(x, y) = -2*W*(y-ay) + 2*H*(x-ax);
         f(x,y)有如下性質:
         f(x, y) < 0, 那么(x, y)在直線上方
         f(x, y) > 0, 那么(x, y)在直線下方

現考慮 點L(Px+1, Py), 點U(Px+1, Py+1), 則LU中點M(Px+1, Py+1/2) 有:
         如果f(Mx, My) < 0, 則M在理想直線上方, 所以選擇L
         如果f(Mx, My) > 0, 則M在理想直線下方, 所以選擇U
則:
         f(Mx,My) = -2*w*(Py+1/2-ay) + 2*H*(Px+1-ax)
當 x從Px+1移動到Px+2時, 考慮f變化M'和M'':
         M':在前一步沒有增加y, M' = (Px+2, Py+1/2)
         M'':在前一步增加了y, M' = (Px+2, Py+3/2)
對于 M':
         f(M'x, M'y) = -2*w*(Py+1/2-ay) + 2*H*(Px+2-ax) = f(Mx, My) + 2 * H
對于 M'':
         f(M''x, M''y) = -2*w*(Py+3/2-ay) + 2*H*(Px+2-ax) = f(Mx, My) - 2 * (W-H)
所以
         對于下一個“測試量”都有一個常數增量:前一次沒有增加y,增量為2*H,如果增加了y,則增量為-2*(W-H)

對于初始條件:x = ax, y = ay
         M = (ax+1, ay+1/2);
         f(Mx, My) = -2*W*(ay+1/2-ay) + 2*H(ax+1-ax) = 2*H-W

Code:
#include <stdlib.h>
#include 
<math.h>
#include 
<GL/glut.h>

void myInit() {
    glClearColor(
1.01.01.00.0);
    glColor3f(
0.00.00.0);
    
//glPointSize(2.0);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluOrtho2D(
0.0640.00.0480.0);
}


void setPixel(int x, int y) {
    glBegin(GL_POINTS);
    glVertex2i(x, y);
    glEnd();

}


void lineBres(int xs, int ys, int xe, int ye) {
    
int W = xe - xs, H = ye - ys, f = 2 * H - W, tH = 2 * H, tHW = 2 * (H - W);
    
int x, y;
    
if (xs > xe) {
        x 
= xe;
        y 
= ye;
        xe 
= xs;
    }
 else {
        x 
= xs;
        y 
= ys;            
    }

    
while (x <= xe) {
        setPixel(x, y);
        x
++;
        
if (f<0{
            f 
+= tH;
        }
 else {
            y
++;
            f 
+= tHW;
        }

    }

}


void myDisplay() {
    glClear(GL_COLOR_BUFFER_BIT);
    lineBres(
2010300180);
    glFlush();
}


int main(int argc, char **argv) {
    glutInit(
&argc, argv);
    glutInitDisplayMode(GLUT_SINGLE
|GLUT_RGB);
    glutInitWindowSize(
640480);
    glutInitWindowPosition (
100150);
    glutCreateWindow(
"Bresenham畫線");
    glutDisplayFunc(myDisplay);
    myInit();
    glutMainLoop();
    
return 0;
}

         
posted @ 2007-10-11 11:57 豪 閱讀(1166) | 評論 (0)編輯 收藏
擴展了一點,有興趣的可以去看看,MFC去,sigh~
http://m.shnenglu.com/qywyh/articles/32740.html
posted @ 2007-09-23 21:34 豪 閱讀(1427) | 評論 (0)編輯 收藏
僅列出標題
共18頁: 1 2 3 4 5 6 7 8 9 Last 
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            亚洲一区一卡| 亚洲国产综合视频在线观看| 亚洲伦理在线免费看| 亚洲精品一区二区三区四区高清| 欧美日韩在线精品一区二区三区| 亚洲女同同性videoxma| 欧美一区二区三区日韩| 亚洲日本aⅴ片在线观看香蕉| 99国产精品久久久| 国产综合激情| 日韩一级在线观看| 尤物视频一区二区| 亚洲宅男天堂在线观看无病毒| 亚洲第一在线综合网站| 亚洲一级网站| 欧美日韩在线一区二区三区| 欧美一区=区| 欧美成人午夜激情在线| 欧美在线观看天堂一区二区三区| 嫩草影视亚洲| 久久精品首页| 国产精品男gay被猛男狂揉视频| 欧美激情精品久久久六区热门 | 亚洲电影免费| 亚洲一二三区精品| 一区二区三区波多野结衣在线观看| 久久精品91| 欧美一区二区三区视频| 欧美日精品一区视频| 亚洲高清av| 狠狠入ady亚洲精品| 亚洲欧美日韩一区二区三区在线| 日韩午夜剧场| 欧美肥婆bbw| 欧美成人精品在线播放| 狠狠色丁香婷婷综合影院| 亚洲欧美日本伦理| 香蕉av福利精品导航| 欧美午夜精品电影| 一本一本久久a久久精品综合麻豆 一本一本久久a久久精品牛牛影视 | 久久久免费精品视频| 欧美在线网址| 国产精品一卡二卡| 亚洲深夜影院| 亚洲欧美日韩国产成人| 欧美视频一区在线观看| 99国内精品久久久久久久软件| 亚洲精品美女在线观看播放| 狼人社综合社区| 欧美国产成人在线| 最新69国产成人精品视频免费| 久久婷婷一区| 欧美二区在线看| 亚洲精品乱码久久久久久日本蜜臀| 久久在精品线影院精品国产| 欧美成人精品影院| 亚洲欧洲精品成人久久奇米网| 美女诱惑一区| 亚洲精品1区| 99精品国产在热久久| 欧美精品色网| 亚洲色图自拍| 欧美与黑人午夜性猛交久久久| 国产日产高清欧美一区二区三区| 欧美一区二区三区在线免费观看| 久久麻豆一区二区| 亚洲激情一区| 欧美三级网页| 欧美在线首页| 欧美激情视频在线免费观看 欧美视频免费一 | 欧美紧缚bdsm在线视频| 欧美日韩成人综合天天影院| 亚洲精品日韩精品| 亚洲一区制服诱惑| 国产日韩欧美不卡在线| 久久国产精品亚洲va麻豆| 欧美91大片| 一区二区三区免费网站| 国产精品天天摸av网| 久久久国产成人精品| 亚洲国内自拍| 性色一区二区| 亚洲韩国日本中文字幕| 欧美性猛交视频| 久久精品国产v日韩v亚洲| 91久久精品国产| 久久超碰97人人做人人爱| 91久久精品国产| 国产精品网站视频| 嫩草影视亚洲| 午夜精品久久久久久久白皮肤| 亚洲人成网在线播放| 精品成人国产在线观看男人呻吟| 欧美福利一区二区三区| 亚洲一区一卡| 亚洲国产精品久久久久久女王| 亚洲欧美综合国产精品一区| 在线观看中文字幕不卡| 国产精品av久久久久久麻豆网| 欧美在线精品免播放器视频| 日韩视频免费观看| 免费不卡欧美自拍视频| 亚洲综合色激情五月| 亚洲韩国青草视频| 国产一区二区三区黄视频| 欧美日韩在线三级| 欧美插天视频在线播放| 久久国产欧美| 亚洲色图在线视频| 亚洲精品一区中文| 欧美韩日精品| 久久米奇亚洲| 欧美一区亚洲二区| 亚洲一区视频在线观看视频| 亚洲日本久久| 亚洲国产黄色| 极品日韩av| 国产午夜精品一区二区三区视频| 欧美日韩国产综合网| 免费中文字幕日韩欧美| 久久精品成人一区二区三区| 亚洲欧美另类在线观看| 99re视频这里只有精品| 亚洲黄一区二区三区| 欧美成人三级在线| 美日韩免费视频| 美女日韩欧美| 久久综合伊人| 久久综合给合久久狠狠色| 欧美一区二区三区免费观看| 亚洲一区二区三区午夜| 中文网丁香综合网| 国产精品99久久久久久白浆小说| 亚洲欧洲在线视频| 亚洲精品1区2区| 亚洲免费观看| 一本高清dvd不卡在线观看| 日韩一级黄色av| 99精品欧美一区| 亚洲视频每日更新| 亚洲性xxxx| 国产精品久久久久久久午夜片| 中日韩美女免费视频网址在线观看 | 久久久人人人| 久久精品一本| 久久一二三四| 欧美91大片| 欧美激情一区二区三区在线| 欧美激情四色| 日韩午夜在线电影| 亚洲色在线视频| 亚洲影院在线| 欧美一级艳片视频免费观看| 欧美一区2区三区4区公司二百| 欧美一级成年大片在线观看| 久久xxxx精品视频| 麻豆成人精品| 欧美三级资源在线| 国产日韩欧美视频| 亚洲成人自拍视频| 亚洲免费电影在线观看| 亚洲欧美日韩一区二区三区在线| 欧美一区二区三区成人 | 国产精品自在线| 影音先锋亚洲一区| 亚洲调教视频在线观看| 麻豆91精品| 日韩视频一区| 免费中文日韩| 久久亚洲私人国产精品va媚药| 国产亚洲欧美另类一区二区三区| 亚洲欧美激情视频| 久久噜噜噜精品国产亚洲综合 | 亚洲国产高清高潮精品美女| 欧美高清视频一区| 99综合精品| 久久精品视频播放| 欧美精品午夜| 国产一区二区三区四区五区美女| 亚洲国产视频一区二区| 亚洲欧美影院| 欧美风情在线观看| 亚洲桃色在线一区| 久久综合国产精品| 国产精品mm| 91久久国产综合久久| 香蕉久久一区二区不卡无毒影院 | 国产农村妇女毛片精品久久麻豆 | 亚洲欧美日韩另类精品一区二区三区| 久久久亚洲精品一区二区三区| 欧美日韩精品免费在线观看视频| 国产日韩欧美综合精品| 99国产精品久久久久老师| 亚洲狼人精品一区二区三区| 欧美+日本+国产+在线a∨观看| 日韩一级免费| 久久综合久久综合这里只有精品| 国产精品乱码人人做人人爱| 亚洲毛片视频| 蜜桃精品一区二区三区|