天天看點

CF1521A Nastia and Nearly Good Numbers

題目描述

Nastia has 22 positive integers AA and BB . She defines that:

The integer is good if it is divisible by A \cdot BA⋅B ;

Otherwise, the integer is nearly good, if it is divisible by AA .

For example, if A = 6A=6 and B = 4B=4 , the integers 2424 and 7272 are good, the integers 66 , 660660 and 1212 are nearly good, the integers 1616 , 77 are neither good nor nearly good.

Find 33 different positive integers xx , yy , and zz such that exactly one of them is good and the other 22 are nearly good, and x + y = zx+y=z .

輸入格式

The first line contains a single integer tt ( 1 \le t \le 10,0001≤t≤10000 ) — the number of test cases.

The first line of each test case contains two integers AA and BB ( 1 \le A \le 10^61≤A≤10

6

, 1 \le B \le 10^61≤B≤10

6

) — numbers that Nastia has.

輸出格式

For each test case print:

“YES” and 33 different positive integers xx , yy , and zz ( 1 \le x, y, z \le 10^{18}1≤x,y,z≤10

18

) such that exactly one of them is good and the other 22 are nearly good, and x + y = zx+y=z .

“NO” if no answer exists.

You can print each character of “YES” or “NO” in any case.If there are multiple answers, print any.

題意翻譯

題目描述

Nastia有兩個正整數 A,BA,B

如果一個正整數 CC 可以被 A*BA∗B 整除,則稱這個正整數CC為“好數”。

如果一個正整數 CC 不能被 A*BA∗B 整除卻能被AA整除,則稱這個正整數CC為“接近好數”。

請你找出三個正整數 x,y,zx,y,z, 使他們中恰好有一個數是“好數”且另外兩個數是“接近好數”,且滿足x+y=zx+y=z。

輸入格式

第一行一個正整數tt, 表示測試資料的組數。

接下來tt行,每行兩個正整數A,BA,B, 如題意所述。

輸出格式

對于每一組資料,輸出"YES"或"NO",表示是否能找到符合要求的x,y,zx,y,z。如果可以找到答案,在下一行輸出任意一組符合要求的x,y,zx,y,z,以空格隔開。

輸入輸出樣例

輸入

3
5 3
13 2
7 11
           

輸出

YES
10 50 60
YES
169 39 208
YES
28 154 182
           

說明/提示

In the first test case: 6060 — good number; 1010 and 5050 — nearly good numbers.

In the second test case: 208208 — good number; 169169 and 3939 — nearly good numbers.

In the third test case: 154154 — good number; 2828 and 182182 — nearly good numbers.

//隻要保證總長度是偶數,且首尾合法,就一定可以,因為給的字元串裡隻會出現一個(和),其餘一定都是問号 
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	while(n--)
	{
		string s;
		cin>>s;
		if(s.length()%2==0&&s[0]!=')'&&s[s.length()-1]!='(')
		{
			cout<<"YES"<<endl;
		}
		else
		{
			cout<<"NO"<<endl;
		}
	}
	return 0;
}
           
上一篇: Good Numbers
下一篇: WPF參考文檔