Description
With given integers a,b,c, you are asked to judge whether
the following statement istrue: "For any x, if a⋅+b⋅x+c=0,
then x is an integer."
Input
The first line contains only one integer T(1≤T≤2000),
which indicates thenumberof test cases.
For each test case, there is only one line containing
three integers a,b,c(−5≤a,b,c≤5).
Output
or each test case, output “YES” ifthe statement istrue,
or “NO” ifnot.
Sample
Input
3144001131
Output
YES
YES
NO
Train of thought
条件判断入门题
会if()就会做
代码
wrong answer
i don`t known why
#include<stdio.h>#include<math.h>int main()
{
int n;
int a,b,c;
int av;
scanf("%d",&n);
for(int i=1;i<=n;i++){
scanf("%d%d%d",&a,&b,&c);
if(a==0){
if(b==0){
printf("YES\n");
}
elseif(c%b==0){
printf("YES\n");
}
elseprintf("NO\n");
}
//涉及到sqrt()函数为小数 //()elseif(a!=0){
av=b*b-4*a*c;
if(av>=0){
double kg=sqrt(av);
if((int)kg!=kg)printf("NO\n");
elseif(((int)(-b+kg)%(2*a))==0&&((int)(-
b-kg)%(2*a))==0)
printf("YES\n");
}
elseprintf("NO\n");
}
}
return0;
}
Description
Calculate mod (1000000000+7) for given n,m.
Input
Input containstwo integers n,m(1≤n≤1000,0≤m≤10).
Output
Output the answer ina single line.
Sample
Input
100
Output
10
Description
Fascinated withthe computer games, Gabriel even forgets to study. Now she needs to finish her homework, and there is an easy problem:
f(n)=
She is required to calculate f(n) mod2foreach given n. Can you help her?
Input
Multiple test cases. Each test case is aninteger n(0≤n≤) ina single line.
Output
For each test case, output the answer of f(n)mod2.
Sample
Input
2
Output
1
There are n kinds of goods inthe company, with each of them has a inventory ofand direct unit benefit . Now you find due to price changes, for any goods sold onday i, ifits direct benefit is val, the total benefit would be i⋅val.
Beginning fromthefirstday, you can and must sell only one good per dayuntil you can't or don't want to do so. If you are allowed to leave some goods unsold, what's the max total benefit you can getintheend?
Input
The first line contains an integers n(1≤n≤1000).
The second line contains n integers val1,val2,..,valn(−100≤.≤100).
The third line contains n integers cnt1,cnt2,..,cntn(1≤≤100).
Output
Output an integerin a single line, indicating the max total benefit.
Sample
Input
4
-1 -100561112
Output
51
Hint
sell goods whose price with order as -1, 5, 6, 6, the total benefit would be -1*1 + 5*2 + 6*3 + 6*4 = 51.