Delta-wave

Delta-wave

Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other)
Total Submission(s) : 35   Accepted Submission(s) : 9
Font: Times New Roman | Verdana | Georgia
Font Size: ← →

Problem Description

A triangle field is numbered with successive integers in the way shown on the picture below.



The traveller needs to go from the cell with number M to the cell with number N. The traveller is able to enter the cell through cell edges only, he can not travel from cell to cell through vertices. The number of edges the traveller passes makes the length of the traveller's route.

Write the program to determine the length of the shortest route connecting cells with numbers N and M.

Input

Input contains two integer numbers M and N in the range from 1 to 1000000000 separated with space(s).

Output

Output should contain the length of the shortest route.

Sample Input

6 12 

Sample Output

3
 
#include<stdio.h>
#include<math.h>
void find(int n,int &l,int &r,int &level)
{
    int i;
    level=1;
    for(i=1;;i+=2)
    {
        if(n-i<=0)
        {
            l=(n+1)/2;
            r=(i-n)/2+1;
            break;
        }
        level++;
        n-=i;
    }
}

int main()
{
    int m,n;
    int ml,mr,nl,nr,mlevel,nlevel;
    while(scanf("%d%d",&m,&n)!=EOF)
    {
        find(m,ml,mr,mlevel);
        find(n,nl,nr,nlevel);
        printf("%d\n",abs(ml-nl)+abs(mr-nr)+abs(mlevel-nlevel));
    }
    return 0;
}

/*  hdu   Delta-wave 每个数,求出相对顶层的层数 up,相对于三角形左边界的层数 left, 相对于三角形右边界的层数 right

任意两个数的最短路径等于  顶层差 +  左边界差 + 右边界差 */

#include<stdio.h>
#include<math.h>
int abs(int a)
{
    return (a>0)?a:-a;
}
int main()
{
    int m,n;
    int ml,mr,nl,nr;
    int up1,up2,left1,left2,right1,right2;
    while(scanf("%d%d",&m,&n)!=EOF)
    {

        up1 = (int)ceil(sqrt((double)m));	//数m对应从上开始的层数
        ml = (up1-1)*(up1-1)+1;				//up1层最左边数的编号
        mr = up1*up1;		   				//up1层最右边数的编号
        left1 = (m-ml)/2+1;					//从m 到 左边界的层数 
        right1 = (mr-m)/2+1;				//从m 到 到右边界的层数 


        up2 =  (int)ceil(sqrt((double)n));	//数n对应从上开始的层数
        nl = (up2-1)*(up2-1)+1;			    //up2层最左边数的编号
        nr = up2*up2;		   				//up2层最右边数的编号
        left2 = (n-nl)/2+1;					//从n 到 左边界的层数 
        right2 = (nr-n)/2+1;				//从n 到 到右边界的层数 
        printf("%d\n",abs(up2-up1)+abs(left2-left1)+abs(right2-right1));
    }
    return 0;
}*/


### MATLAB Package for Reduced Delta Matrix Method For computing partial derivatives of surface wave dispersion curves using the reduced delta matrix method, several specialized toolboxes and functions are available within MATLAB. One prominent option is the **Disperse Toolbox**, which provides comprehensive functionality specifically designed for seismic wave propagation studies. #### Disperse Toolbox Overview The Disperse Toolbox offers robust algorithms tailored for calculating phase velocities and group velocities of surface waves through various media types. The toolbox includes implementations of advanced methods such as the reduced delta matrix approach, enabling accurate computation of dispersion characteristics including their sensitivities via partial derivative calculations[^1]. To utilize these features effectively: ```matlab % Load necessary parameters into workspace load('model_parameters.mat'); % Initialize model configuration config = disperse_config(); % Define frequency range for analysis frequencies = linspace(0.1, 10, 50); % Compute dispersion curve along with its sensitivity (partial derivatives) [d_curve, d_sensitivity] = compute_dispersion(config, frequencies); ``` This code snippet demonstrates how to set up and perform computations involving both the dispersion curve itself and associated partial derivatives concerning changes in material properties or geometry. #### Key Features Supported by Disperse Toolbox - Efficient handling of complex geological models. - Support for multiple wave modes like Rayleigh and Love waves. - Built-in routines for estimating uncertainties based on perturbation theory principles. - Visualization tools for interpreting results graphically. --related questions-- 1. How can one validate computed dispersion curves against experimental data? 2. What preprocessing steps should be considered before applying the reduced delta matrix technique? 3. Are there alternative numerical approaches comparable to the reduced delta matrix method worth exploring?
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值