B. Make AP【模拟】

Problem - B - Codeforces

Polycarp has 33 positive integers aa, bb and cc. He can perform the following operation exactly once.

  • Choose a positive integer mm and multiply exactly one of the integers aa, bb or cc by mm.

Can Polycarp make it so that after performing the operation, the sequence of three numbers aa, bb, cc (in this order) forms an arithmetic progression? Note that you cannot change the order of aa, bb and cc.

Formally, a sequence x1,x2,…,xnx1,x2,…,xn is called an arithmetic progression (AP) if there exists a number dd (called "common difference") such that xi+1=xi+dxi+1=xi+d for all ii from 11 to n−1n−1. In this problem, n=3n=3.

For example, the following sequences are AP: [5,10,15][5,10,15], [3,2,1][3,2,1], [1,1,1][1,1,1], and [13,10,7][13,10,7]. The following sequences are not AP: [1,2,4][1,2,4], [0,1,0][0,1,0] and [1,3,2][1,3,2].

You need to answer tt independent test cases.

Input

The first line contains the number tt (1≤t≤1041≤t≤104) — the number of test cases.

Each of the following tt lines contains 33 integers aa, bb, cc (1≤a,b,c≤1081≤a,b,c≤108).

Output

For each test case print "YES" (without quotes) if Polycarp can choose a positive integer mm and multiply exactly one of the integers aa, bb or cc by mm to make [a,b,c][a,b,c] be an arithmetic progression. Print "NO" (without quotes) otherwise.

You can print YES and NO in any (upper or lower) case (for example, the strings yEs, yes, Yes and YES will be recognized as a positive answer).

Example

input

Copy

11
10 5 30
30 5 10
1 2 3
1 6 3
2 6 3
1 1 1
1 1 2
1 1 3
1 100000000 1
2 1 1
1 2 2

output

Copy

YES
YES
YES
YES
NO
YES
NO
YES
YES
NO
YES

Note

In the first and second test cases, you can choose the number m=4m=4 and multiply the second number (b=5b=5) by 44.

In the first test case the resulting sequence will be [10,20,30][10,20,30]. This is an AP with a difference d=10d=10.

In the second test case the resulting sequence will be [30,20,10][30,20,10]. This is an AP with a difference d=−10d=−10.

In the third test case, you can choose m=1m=1 and multiply any number by 11. The resulting sequence will be [1,2,3][1,2,3]. This is an AP with a difference d=1d=1.

In the fourth test case, you can choose m=9m=9 and multiply the first number (a=1a=1) by 99. The resulting sequence will be [9,6,3][9,6,3]. This is an AP with a difference d=−3d=−3.

In the fifth test case, it is impossible to make an AP.

题意:给你三个数a,b,c 判断某个数乘以一个正整数m,能否使该三个数为等差数列。

 

 咳咳,这图。。

#include<iostream>
using namespace std;
int t;
int a,b,c;
int main()
{
    scanf("%d", &t);
    while(t--)
    {
        int flag=0;
        scanf("%d %d %d",&a,&b,&c);
        if(b-a==c-b)flag=1;
        else
        {
            int x=(b-(c-b));
            int y=(c-((c-a)/2));
            int z=(b+(b-a));
            if((x%a==0)&&x>0)
            {
                a*=x/a;
                if(b-a==c-b)
                  flag=1;
                
            }
            else if(y%b==0&&y>0)
            {
                b*=y/b;
               if(b-a==c-b)
                flag=1;
                
            }
            else if(z%c==0&&z>0)
            {
                c*=z/c;
               if(b-a==c-b)
                flag=1;
              
            }
        }
        if(flag)cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
}

### 绘制 AdaBoost 的 Precision-Recall (PR) 曲线 为了绘制 AdaBoost 模型的 Precision-Recall (PR) 曲线,可以采用 Python 中 `scikit-learn` 库提供的工具来实现这一目标。以下是具体方法: #### 准备据集并训练模型 首先,准备用于训练的据集,并利用这些据训练一个 AdaBoost 分类器。 ```python from sklearn.datasets import make_classification from sklearn.model_selection import train_test_split from sklearn.ensemble import AdaBoostClassifier # 创建模拟二分类据集 X, y = make_classification(n_samples=1000, n_features=20, n_informative=2, n_redundant=10, random_state=7) # 将据分为训练集和测试集 X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, stratify=y, random_state=42) # 训练 AdaBoost 模型 model = AdaBoostClassifier() model.fit(X_train, y_train) ``` #### 获取预测概率分 接着,在测试集上应用已训练好的 AdaBoost 模型获取样本属于正类的概率估计值。 ```python y_scores = model.predict_proba(X_test)[:, 1] ``` #### 使用 scikit-learn 绘制 PR 曲线 最后一步是计算 precision 和 recall 值,并通过 matplotlib 或 seaborn 来可视化 PR 曲线。 ```python import numpy as np import matplotlib.pyplot as plt from sklearn.metrics import precision_recall_curve, average_precision_score precision, recall, _ = precision_recall_curve(y_test, y_scores) average_precision = average_precision_score(y_test, y_scores) plt.figure(figsize=(8,6)) plt.step(recall, precision, color=&#39;b&#39;, alpha=0.2, where=&#39;post&#39;) plt.fill_between(recall, precision, step=&#39;post&#39;, alpha=0.2, color=&#39;b&#39;) plt.xlabel(&#39;Recall&#39;) plt.ylabel(&#39;Precision&#39;) plt.ylim([0.0, 1.05]) plt.xlim([0.0, 1.0]) plt.title(f&#39;2-class Precision-Recall curve: AP={average_precision:.2f}&#39;) plt.show() ``` 上述代码展示了如何基于给定的测试据及其对应的预测得分构建 PR 曲线图表[^1]。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值