Cold and cold ice rain on your face, cold and cold ice rain on your face
Package test; public class TestSizeMatch {public static void main (String [] args) {int [] a = {1280,720}; int [] B = {800,1200}; System. out. println (TestSizeMatch. calAdSizeSimilarRatio (a, B);} public static double calAdSizeSimilarRatio (int [] reqAdsize, int [] adSize) {if (null = reqAdsize | null = adSize) return 0; double rateRate, lenRate; // proportional difference, length difference double dLenVal = reqAdsize [0] * reqAdsize [0] + reqAdsize [1] * reqAdsize [1]; double dRateVal = (double) reqAdsize [1])/reqAdsize [0]; final int RATE_WEIGHT = 3; // 2 is the ratio magnification, which is the empirical value final int LEN_WEIGHT = 1; double dVal = adSize [0] * adSize [0] + adSize [1] * adSize [1]; lenRate = Math. sqrt (dVal/dLenVal); if (lenRate> 1) lenRate = 1/lenRate; rateRate = (double) adSize [1])/adSize [0])/dRateVal; // if (rateRate> 1) rateRate = 1/rateRate; return (RATE_WEIGHT * rateRate + LEN_WEIGHT * lenRate) /(RATE_WEIGHT + LEN_WEIGHT ));}}