zoukankan      html  css  js  c++  java
  • hdu 5585 Numbers【大数+同余定理】

    Numbers

    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
    Total Submission(s): 460    Accepted Submission(s): 283


    Problem Description
    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)
     
    Output
    For each test case,output the answer in a line.
     
    Sample Input
    2
    3
    5
    7
     
    Sample Output
    YES
    YES
    YES
    NO
     
    注意:n是大数,求n是否是2或者3或者5的倍数
    #include<stdio.h>
    #include<string.h>
    #include<algorithm>
    #define LL long long
    #define MAX 1010
    using namespace std;
    int main()
    {
    	LL n,m,j,i,k;
    	char s[50];
    	while(scanf("%s",s)!=EOF)
    	{
    		int len=strlen(s);
    		int sum1,sum2,sum3;
    		sum1=sum2=sum3=0;
    		for(i=0;i<len;i++)
    		{
    			sum1=sum1*10+s[i]-'0';
    			sum1=sum1%2;
    			sum2=sum2*10+s[i]-'0';
    			sum2=sum2%3;
    			sum3=sum3*10+s[i]-'0';
    			sum3=sum3%5;
    		}
    		if(sum1==0||sum2==0||sum3==0)
    		printf("YES
    ");
    		else
    		printf("NO
    ");
    	}
    	return 0;
    } 
    

      

     
  • 相关阅读:
    spring boot所有配置
    Hibernate validator的一些额外特性
    相似序列搜索
    时间序列异常检测
    基于结构的距离度量
    jupyterlab的启动404error问题
    爬虫-Chrome-问题1
    厘清重要概念的内涵与外延
    六)定时任务持久化
    公钥私钥
  • 原文地址:https://www.cnblogs.com/tonghao/p/5018970.html
Copyright © 2011-2022 走看看