【HDU - 5585】Numbers (水题,数学,数论)
生活随笔
收集整理的這篇文章主要介紹了
【HDU - 5585】Numbers (水题,数学,数论)
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
題干:
There is a number N.You should output "YES" if N is a multiple of 2, 3 or 5,otherwise output "NO".
Input
There are multiple test cases, no more than 1000 cases.?
For each case,the line contains a integer N.(0<N<1030)(0<N<1030)
Output
For each test case,output the answer in a line.
Sample Input
2 3 5 7Sample Output
YES YES YES NO解題報(bào)告:
? ? 水題啊。判斷是否是2,3,5的倍數(shù)。
AC代碼:
#include<cstdio> #include<cstring> #include<algorithm> #include<iostream> #define ll long long using namespace std; char s[100005]; int main() {while(~scanf("%s",s+1)) {int len = strlen(s+1);ll sum = 0;for(int i = 1; i<=len; i++) {sum += s[i] - '0';}if(sum%3==0 || (s[len] - '0') %2 == 0 || (s[len] - '0' == 5)) puts("YES");else puts("NO");}return 0 ;}?
總結(jié)
以上是生活随笔為你收集整理的【HDU - 5585】Numbers (水题,数学,数论)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 富国基金有哪些值得推荐的基金?富国基金的
- 下一篇: 【CF#192 A】Funky Numb