1. 程式人生 > >A+B問題 HDU-2101

A+B問題 HDU-2101

A+B問題 HDU-2101

時限:1000 ms 記憶體限制:32768 kB
OS:窗 來源:HDU 2007-6程式設計比賽

Problem Description:This problem is also a A + B problem,but it has a little difference,you should determine does (a+b) could be divided with 86.For example ,if (A+B)=98,you should output no for result.

Input:Each line will contain two integers A and B. Process to end of file.

Output:For each case, if(A+B)%86=0,output yes in one line,else output no in one line.

Sample Input:
1 1
8600 8600

Sample Output:
no
yes

問題連結:A+B問題 HDU-2101
問題描述:給出多組資料(A和B),問A+B是否能整除86,若能,輸出“yes”,反之輸出“no”(不包括雙引號).
問題分析:簡單的運算和判斷語句的使用,有兩個點要注意:(1)有多組資料;(2)判斷兩數是否相等時,應使用邏輯運算子“==“,而不是賦值運算子"="。
AC程式碼如下:

#include <iostream>
using namespace std;
int main()
{
	long A, B;
	while (cin >> A >> B)
	{
		if ((A + B) % 86 == 0)
			cout << "yes" << endl;
		else
			cout << "no" << endl;
	}
}