(HDU)5832 - A water problem【大数取模】

hdu5832(大数取模) A water problem Time Limit: 5000/2500 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 3394    Accepted Submission(s): 1221 Problem Description Two planet 阅读详情

A water problem

Time Limit: 5000/2500 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 1851    Accepted Submission(s): 739


Problem Description
Two planets named Haha and Xixi in the universe and they were created with the universe beginning.

There is 73 days in Xixi a year and 137 days in Haha a year. 

Now you know the days N after Big Bang, you need to answer whether it is the first day in a year about the two planets.
 

Input
There are several test cases(about 5 huge test cases).

For each test, we have a line with an only integer N(0≤N), the length of N is up to 10000000.
 

Output
For the i-th test case, output Case #i: , then output "YES" or "NO" for the answer.
 

Sample Input
10001 0 333
 

Sample Output
Case #1: YES Case #2: YES Case #3: NO
 

Author
UESTC
 
题意:判断一个大数能否同时被73和137整除。

分析:大数取模直接水过去,把大数拆成一位位的取模相加。

#include <bits/stdc++.h>

using namespace std;

int main()
{
    char s[10000010];
    int i,len,ans,kase=0;
    while(~scanf("%s",s))
    {
        len=strlen(s),ans=0;
        for(i=0;i<len;i++)
        {
            ans=10*ans+s[i]-'0';
            ans%=10001;
        }
        printf("Case #%d: ",++kase);
        if(ans) printf("NO\n");
        else printf("YES\n");
    }
    return 0;
}

这题因为73和137互质,所以只要对他们乘积10001取模就可以了,正常套路是下面的代码:
#pragma comment(linker, "/STACK:1024000000,1024000000")  
#include<stdio.h>  
#include<string.h>  
#include<stdlib.h>  
#include<queue>  
#include<stack>  
#include<math.h>  
#include<vector>  
#include<map>  
#include<set>  
#include<cmath>  
#include<complex>  
#include<string>  
#include<algorithm>  
#include<iostream>  
#define eps 1e-9  
#define LL long long  
#define bitnum(a) __builtin_popcount(a)  
using namespace std;  
const int N = 10000005;  
const int M = 10005;  
const int inf = 1000000007;  
const int mod = 1000000007;  
char s[N];  
int main()  
{  
    int ans1,ans2,p=1,i,k;  
    while(~scanf("%s",s))  
    {  
        ans1=ans2=0;  
        k=strlen(s);  
        for(i=0;i<k;i++)  
        {  
            ans1=(ans1*10+s[i]-'0')%73;  
            ans2=(ans2*10+s[i]-'0')%137;  
        }  
        if(!ans1&&!ans2)  
            printf("Case #%d: YES\n",p++);  
        else  
            printf("Case #%d: NO\n",p++);  
    }  
    return 0;  
}  




java大数运算,包括加减乘除 自己编写的Java大数字运算函数,没有使用Java自带的运算函数,支持特大int型数据的运算 立即下载

相关推荐

RedPitaya火龙果板基础操作

火龙果板基础操作一级目录二级目录三级目录 一级目录 二级目录 三级目录

qq_41523340的博客 9731

HDU5832(大数取模-秦九昭算法)

大数取模-采用秦九昭算法 #include<iostream> #include<algorithm> #include<cmath> #include<cstring> using namespace std; const int maxx=1e7+10; const int mod=10001; int main(){ char A[maxx]; int b; int count=1; while(scanf("%s",A)!=EOF){ i

Keep_Trying_Go的博客 562

《揭秘 BME688人工智能压力湿度温度气体传感器:气体检测的多面能手》:此文为AI自动生成

BME688 是博世推出的一款具有人工智能和集成高线性度高精度压力、湿度、温度传感器的气体传感器,专为移动和联网应用开发,尺寸紧凑且低功耗。BME688 作为一款先进的传感器,在多个领域展现出卓越的性能。它采用了坚固而紧凑的 3.0 x 3.0 x 0.9 mm³ 封装,这种小巧的尺寸使其能够轻松应用于对空间要求严格的移动设备和联网应用中。同时,低功耗的特性也使得它在能源有限的环境下能够长时间稳定运行。

zheng_ruiguo的专栏 1935

HDU 5832 A water problem (水题)

A water problem Time Limit: 5000/2500 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 97    Accepted Submission(s): 58 Problem Description Two planets name

aozil_yang的博客 1544

79.ScottPlot的MVVM实现 C#例子 WPF例子

在你的 WPF 窗口的 XAML 文件中,定义一个,并将其Content属性绑定到 ViewModel 中的属性。这样可以将WpfPlot控件动态绑定到 ViewModel。

S13461120713的博客 2571

基于 STM32 的乒乓球发球机控制系统设计与实现

乒乓球发球机是一种能够按照预设参数自动、连续发出乒乓球的训练设备。本系统以 STM32F103C8T6 为主控核心,通过控制实现球速调节、实现落点与旋转方向控制、实现出球节奏控制,并配合 OLED 显示与按键人机交互,实现速度、频率、落点、旋转四大参数的可调发球训练。

weixin_42300449的博客 211

hdu 5832

这个题告诉我,一定要冷静,莫莫伤心流泪啊。#include #include using namespace std; char a[10000005]; int main() { long long cnt,ans,i,cas=1,len,cnt1; while(scanf("%s",a)!=EOF) { printf("Case #%d: ",cas++

fanbaobao829的博客 389

开源模型应用落地-qwen模型小试-Qwen3-8B-快速体验(一)

阿里云推出国内首个集成“快思考”与“慢思考”能力的 Qwen3-8B 大语言模型,以80亿参数和 128K 上下文支持,重塑AI应用边界并助力开发者高效部署

以微薄之力,予他人些许温暖. 2万+

hdu5832 A water problem (大数求余)

hdu5832 A water problem (大数求余):http://acm.hdu.edu.cn/showproblem.php?pid=5832 题目描述: 合训练的同学们~  A water problem Time Limit: 5000/2500 MS (Java/Others)    Memory Limit: 65536/65

而濡木染 702

R语言dplyr包recode函数、recode_factor函数数值或因子替换实战

R语言dplyr包recode函数、recode_factor函数数值或因子替换实战 目录 R语言dplyr包recode函数、recode_factor函数数值或因子替换实战 #导入dplyr包 #recode函数进行数值替换 #recode_factor函数对因子变量进行替换 #导入dplyr包 install.packages("dplyr") # Install & load dplyr library("dpl.

data+scenario+science+insight 1592

《PCI Express体系结构导读1》-- PCI简介

请先阅读完一遍此书再来看文章哦,这样效率更高~

HoneyIC的博客 152

HDU 5832 A water problem 【大数取模,Java 大数也不是万能的。。】

A water problem Description Two planets named Haha and Xixi in the universe and they were created with the universe beginning. There is 73 days in Xixi a year and 137 days in Haha a year.

AC_Dreameng 1832

lwip-2.0.3

lwip是瑞典计算机科学院(SICS)的Adam Dunkels 开发的一个小型开源的TCP/IP协议栈。实现的重点是在保持TCP协议主要功能的基础上减少对RAM 的占用。

【HDU 5832】A water problem(大数取模)

1千万长度的数对73和137取模。(两个数有点像,不要写错了) 效率要高的话,每15位取一次模,因为取模后可能有3位,因此用ll就最多15位取一次。 一位一位取模也可以,但是比较慢,取模运算是个耗时的运算。 #include <cstdio> #define ll long long ll n,m; int p,cas; char s[10000005]; ...

dingguayi7025的博客 140

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

HDU 5832 / HDU 1212 A water problem (大数取模)

原文链接: HDU 5832 / HDU 1212 A water problem (大数取模) ...

阿豪 133

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

hdu 5832 A water problem(大数取模)

题目链接思路:大数取模,73*137=10001,所以对10001取模代码 #include<stdio.h> #include<iostream> #include<algorithm> #include<string.h> #include<map> #include<queue> #define LL long long using namespace std; const int N=100

跟随内心的渴望 322

大数取模-HDU 5832-A water problem

大数取模-HDU 5832-A water problem 题目链接: A water problem 思路: 题目大意: 第一颗星球周期为73,第二颗星球周期为137,问N是否为两颗星期的共同周期第一天 题目思路: 把两个周期的最小公倍数求出,是10001,只要那个数能被10001整除就YES 看看N的取值: the length of N is up to 1...

[SZU_Crayon] 359

hdu 5832 A water problem 大数取模问题 大水

大数取模问题,模拟除法,从第一个数字开始不断地对10001取模即可 #include #include #include using namespace std; char s[10000010]; int main() { int cnt = 1; while(~scanf("%s", s)){ int mod = 0; for(int

sdut_jean的博客 326

HDU - 5832 -A water problem【大数取模】

题解:因为137*73=10001,则将值对10001取模。 #include&lt;iostream&gt; #include&lt;cstring&gt; #include&lt;cstdio&gt; #define mod 10001 using namespace std; const int maxn = 1e7 + 5; char a[maxn]; int main() { ...

北里五井的博客 223

HDU-5832-A water problem(大数取模/模拟加法)

A water problem Problem Description Two planets named Haha and Xixi in the universe and they were created with the universe beginning. There is 73 days in Xixi a year and 137 days in Haha a year. Now ...

qq_43461168的博客 302

HDU 5832 A water problem(某水题)

HDU5832Awaterproblem(某水题) TimeLimit:5000/2500MS(Java/Others)MemoryLimit:65536/65536K(Java/Others) ProblemDescription - 题目描述 TwoplanetsnamedHahaandXixiintheu...

168

HDU 5832 A water problem (大数取模)

A water problem Time Limit: 5000/2500 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 496    Accepted Submission(s): 26 Problem Description Two planets named H

LzyRapX 730

HDU5832 A water problem【大数模除】

A water problem Time Limit: 5000/2500 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 5419 Accepted Submission(s): 1768 Problem Description Two planets named Haha...

海岛Blog 676

HDU 5832 A water problem (高精度取模)

hdu 5832 题目: Problem Description Two planets named Haha and Xixi in the universe and they were created with the universe beginning. There is 73 days in Xixi a year and 137 days in Haha a year. Now ...

Kruskal的博客 286

hdu 5832 A water problem

A water problem Time Limit: 5000/2500 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 177    Accepted Submission(s): 95 Problem Description Two planets named

Tyshawn的博客 1248
上一篇: Manacher's ALGORITHM: O(n)时间求字符串的最长回文子串
下一篇: (HDU)5833 - Zhu and 772002 【高斯消元】
ACDoge
博客等级 码龄10年 8粉丝 62原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值