HDU 5832 A water problem
来源:互联网 发布:网站访客qq获取源码 编辑:程序博客网 时间:2024/05/16 12:34
HDU 5832 A water problem
编程能力题,大数
想当初打网预时这题。。写了半天JAVA,都是MLE。。C++大数的板子也各种挂。。最后队友过的这题。。赛后也没去看。。现在回忆一下,补个题解,长个见识。
传送门:HDU
题意
给你一个很大的数,数字位数有10000000个。问你它是不是73和137的倍数。
思路
同时是73和137的倍数,这数必定是10001(137*73)的倍数。
一个数字一个数字的处理,再利用取模的性质,可以得到 res=(res*10+a)%mod
想不明白的话想想一个数字一个数字读入,怎么转化成一个数?就是读一个数字,把原来结果*10加上它。
代码
#include<cstdio>#include<cstdlib>#include<iostream>#include<algorithm>#include<string>#include<cstring>#include<vector>#include<cmath>#include<queue>#define _ ios_base::sync_with_stdio(0);cin.tie(0);using namespace std;const int MAXN=5005;const int oo=0x3f3f3f3f;typedef long long LL;const LL loo=4223372036854775807ll;const int MOD=73*137;char a[10000007];int main(){_ int res=0; int count=0; while(scanf("%s",a)==1) { for(int i=0;i<strlen(a);i++) { res=(res*10+(a[i]-'0'))%MOD; } cout<<"Case #"<<++count<<": "; cout<<(res==0 ? "YES" : "NO")<<endl; res=0; } //system("pause"); return 0;}
0 0
- hdu 5832 A water problem
- HDU 5832 A water problem
- hdu 5832 A water problem
- HDU 5832 A water problem
- HDU 5832 A water problem
- HDU 5832 A water problem
- HDU 5832 A water problem (水题)
- HDU 5832 A water problem【大数问题】
- HDU 5832 A water problem(水~)
- HDU 5832A water problem 简单模拟
- 【2016-CCPC-A】水题(A water problem,hdu 5832)
- hdu 5832 A water problem 2016icpc网络赛
- hdu 5832 A water problem【大数取膜】
- HDU-5832 A water problem(特殊的取模方法)
- hdu 5832 A water problem(简单数论)
- HDU 5832:A water problem (大数整除)
- HDU 5832 A water problem (大数取模)
- hdu 5832 A water problem(大数取模)
- codeforces 763B. Timofey and rectangles [思维]【智商】
- Mysql使用navicat 结果集部分未显示
- 运行我的第一个python程序
- 每天一个Linux命令6(rm命令)
- HDU 4431 Mahjong 第37届ACM/ICPC 天津赛区现场赛A题
- HDU 5832 A water problem
- 10017---Why are you living your present job
- set 续4
- JavaScript内置对象——Math对象
- Access denied for user 'root'@'localhost' (using password: YES)"
- 朱刘算法
- 【PAT】1015. Reversible Primes
- css计数器小记
- Java 多线程之线程安全