1. 程式人生 > >ACM第一期練習題第八小題:A + B Problem Too

ACM第一期練習題第八小題:A + B Problem Too

click here to have a try first
題目要求:
Time limit : 1000 ms
Memory : 32768 KB

題目原題:

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

問題簡述:
輸入兩個數字,兩個數字之間以空格分開,計算兩個數字相加的和除於86的餘數是否為零,若是在下一行輸出yes,否在下一行輸出yes,且要求可以輸入多組資料。

問題分析:

考慮利用while()來創造輸入多組資料的條件。
Virtua Judge通過的程式碼為:

#include <iostream>
using namespace std; int main() { int A, B; while (scanf_s("%d%d", &A, &B)!=EOF) { if ((A + B) % 86 == 0) { printf("yes\n"); } else { printf("no\n"); } } return 0; }