UVA 10494 - If We Were a Child Again(大数除法和取模)

48V电气架构全面科普和解析:下一代智能电动汽车核心驱动 随着电动汽车(EV)技术的不断发展,传统的12V电力系统已经逐渐无法满足日益增长的功率需求,尤其是在电动汽车中,48V电气系统的引入成为了一种理想的解决方案。在电动汽车中,48V系统与Zonal架构的结合,不仅有效提升了车辆电力系统的能效,还为未来的技术升级提供了灵活的设计基础。随着电动汽车(EV)技术的发展,车辆电气系统的工作电压逐步从传统的12V系统向更高的电压过渡。随着电动汽车技术的不断进步,传统的12V电气系统逐渐无法满足现代高性能电动汽车的需求,而48V电力系统的引入成为一种理想的解决方案。 阅读详情

If We Were a Child Again

Input: standard input
Output: standard output

Time Limit: 7 seconds

 

“Oooooooooooooooh!

If I could do the easy mathematics like my school days!!

I can guarantee, that I’d not make any mistake this time!!”

Says a smart university student!!

But his teacher even smarter – “Ok! I’d assign you such projects in your software lab. Don’t be so sad.”

“Really!!” - the students feels happy. And he feels so happy that he cannot see the smile in his teacher’s face.

 

 

The Problem

 

The first project for the poor student was to make a calculator that can just perform the basic arithmetic operations.

 

But like many other university students he doesn’t like to do any project by himself. He just wants to collect programs from here and there. As you are a friend of him, he asks you to write the program. But, you are also intelligent enough to tackle this kind of people. You agreed to write only the (integer) division and mod (% in C/C++) operations for him.

 

Input

Input is a sequence of lines. Each line will contain an input number. One or more spaces. A sign (division or mod). Again spaces. And another input number. Both the input numbers are non-negative integer. The first one may be arbitrarily long. The second number n will be in the range (0 < n < 231).

 

 
Output

A line for each input, each containing an integer. See the sample input and output. Output should not contain any extra space.

 

 
 
Sample Input

110 / 100

99 % 10

2147483647 / 2147483647

2147483646 % 2147483647

 

 

 

 

 
 
Sample Output

1

9

1

2147483646

 

 

 

 


Problemsetter:  S. M. Ashraful Kadir, University of Dhaka


====================================

注意中间数据范围有时会超出int要用long long

除法要注意第一个数比第二个数小的情况(在这里WA了orz)


#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

long long ans,s[1111];
char str[1111];

void div(char a[],long long b)
{
    memset(s,0,sizeof(s));
    int len=strlen(a),i,j=0,flag=0;
    long long temp=0;
    ans=0;
    for(i=0;i<len;i++)
    {
        //cout<<ans<<endl;
        if((temp*10+a[i]-'0')/b>0||flag==1)//控制前面的0不存入s
        {
            s[j]=(temp*10+a[i]-'0')/b;
            j++;
            flag=1;
        }
        temp=(temp*10+a[i]-'0')%b;
    }
    if(!flag)//第一个数比第二个数小时
    {
        printf("0\n");
        return;
    }
    for(int i=0;i<j;i++)
        printf("%lld",s[i]);
    printf("\n");
}

void mod(char a[],int b)
{
    int len=strlen(a);
    ans=0;
    for(int i=0;i<len;i++)
    {
        ans=(ans*10+a[i]-'0')%b;
        //cout<<ans<<endl;
    }
    cout<<ans<<endl;
}

int main()
{
    long long n;char c;
    while(~scanf("%s %c %lld",str,&c,&n))
    {
        if(c=='/')
        {

            div(str,n);
        }
        else
        {
            mod(str,n);
        }
    }
    return 0;
}


Matlab R2018b简体中文版完整安装图文教程(附安装包下载) 目 录 一、安装过程 二、下载地址 matlab R2018b安装包如下所示,包括主程序和补丁文件两部分。 一、安装过程 双击安装包中的setup.exe。 选择使用文件安装MIYAO,点击下一步。 接受协议,选择是,点击下一步。 输入序列号:09806-07443-53955-64350-21751-41297,点击下一步。 修改安装路径,点击下... 阅读详情

相关推荐

封神台靶场,为了小芳,冲之——cookie注入

第二个靶场 打开网站 找一下注入点 一般在新闻这种里面点开看看 先判断是否存在注入 有waf 尝试了很多方法绕过都没成功,/and/,aandnd,AnD等一系列都没绕过去,乌鸡鲅鱼 删掉id=169 发现 然后判断cookie注入 在搜索框输入 Javascript:alert(document.cookie=”id=”+escape(‘169’)); 然后弹窗了(其中 “id=” 取决URL中的id= escape中的数值也是URL中id=的值)返回刚刚的页面,把ID删除后一样能正常显示。说明服务器能

Wubuqing的博客 666

【BIT2021程设】8. 军训日记:报数!——循环节、快速幂、欧拉扩展定理

写在前面: 本系列博客仅作为本人十一假期过于无聊的产物,对小学期的程序设计作业进行一个总结式的回顾,如果将来有BIT的学弟学妹们在百度搜思路时翻到了这一条博客,也希望它能对你产生一点帮助(当然,依经验来看,每年的题目也会有些许的不同,所以不能保证每一题都覆盖到,还请见谅)。 不过本人由于学艺不精,代码定有许多不足之处,欢迎各位一同来探讨。 同时请未来浏览这条博客的学弟学妹们注意,对于我给出完整代码的这些题,仅作帮助大家理解思路所用(当然,因为懒,所以大部分题我都只给一个伪代码)。Anyway,请勿直接

敲代码的小潘的博客 632

单细胞空间转录组分析流程学习python版(三)

空转python版学习

zfyyzhys的博客 2094

A除B求商(PAT20)高精度/低精度

题目链接:https://www.nowcoder.com/pat/6/problem/4043 手动模拟除法的过程:模板题 #include<iostream> #include<vector> #include<algorithm> using namespace std; //int r=0; vector<int> div(vector...

LiuHu 182

Multisim14.3主数据库访问冲突:Windows更新KB5065426卸载与系统兼容性修复指南

本文针对Multisim14.3在Windows更新KB5065426后出现的主数据库访问冲突问题,提供了详细的解决方案。通过卸载问题更新、修复系统兼容性及调整权限设置,帮助用户快速恢复元器件库的正常访问,确保电路仿真设计的连续性。

lstm7chronicler的博客 532

AIDD-人工智能药物设计-构建基于机器学习方法的在线预测平台高准确预测药物诱导骨毒性

在此基础上,提取多种药物分子特征,包括分子指纹(如MACCS、Morgan、RDKit、TopologicalTorsion、AtomPairs与Descriptors)及分子图谱,通过Transformer编码器与神经网络进行机器学习模型训练。最后,将训练好的模型部署为在线Web服务器(BoneToxPD),供用户快速预测药物的骨毒性。本研究不仅在骨毒性预测的准确性方面取得了突破,还在模型解释性方面提供了新的视角,通过注意力机制精准识别出影响骨毒性的关键化学基团,推动药物研发领域更安全、更高效的发展。

itwangyang520的博客 1097

高精度模板

文章目录一、高精度加法1.分析2.代码二、高精度减法1.分析2.代码三、高精度与低精度乘法1.分析2.代码四、高精度与低精度除法1.分析2.代码五、高精度乘法1.分析2.代码六、高精度除法 一、高精度加法 1.分析 大整数加法 大整数存储:用数组从个位开始存储,方便补位操作,同时最好用vector,方便空间处理和访问大小。 操作:从个位开始操作,每一位由加数,被加数和进位所决定,最后对最高位是否有进位进行判断。 前导0处理:不考虑前导0则可以直接逆序输出,若考虑则先进行判断,找到第一个非0位,保证结果长.

qq_52441682的博客 1066

非华为电脑也能用!华为电脑管家完美安装教程来了

GitHub 上有一个开源项目 ​****​,专门解决“非华为设备无法安装华为电脑管家”的问题。它通过智能模拟 + DLL 劫持技术,绕过官方对硬件型号的检测,让你在联想、戴尔、华硕甚至 DIY 主机上也能流畅使用华为电脑管家!⭐ 项目已获 ​700+ Stars​,社区活跃,持续更新,兼容性优秀!科技不该有围墙。如果你成功在非华为电脑上跑起了 PCManager,欢迎在评论区晒出你的设备型号 + 使用体验!也别忘了把这篇推文分享给同样“眼馋”华为生态的朋友 ~📱 ​关注我们。

程序员朱永胜 5136

UVa 10494 如果我们再回童年

思路:借助long long类型暂存一部分的被除数,即可模拟除法。(这里是从第一位开始除除数,实现起来方便些,可以前九位初始化的) 注意:还是题目没看太好就开始做了吧,首先第二个整数是int型就可以了,结果我一开始做的是两个bign类型相除,所以一直把自己引在bign的这条路上。无奈bign我用减法代替除法都是超时,如果用这里的这个方法做,肯定也可以,但感觉没必要再bign了~所以直接用C语言字

buxizhizhou530的专栏 894

LabVIEW调用.so文件的方法

LabVIEW调用.so文件的方法

m0_37878912的博客 3033

编程助手:CLAUDE.md 与 AGENTS.md 完全指南

AI编程助手配置文件指南 为解决AI编程助手在陌生项目中面临的运行、规范、架构等问题,本文提出两种配置文件: CLAUDE.md(根目录): 面向通用AI(如ClaudeCode) 包含项目命令、代码风格、架构说明等结构化信息 示例:启动命令:npm run dev,代码规范:TypeScript禁用any AGENTS.md(任意目录): 面向智能编码工具(如Cursor) 支持模块级配置(如微前端子应用) 示例:前端测试命令:npm test:web,API请求规范 与传统README.md的区别: 人

分享AI、区块链技术及应用,未来已来 1286

10494 - If We Were a Child Again

#include #include int main() { long long int count,i,num,l; int n,flag; char x[10000]; long long int str[10000]; char c; memset(x,0,sizeof(x)); memset(str,0,sizeof(str));

moyan_min的专栏 469

【Python爬虫教程】第3篇-解决使用reqeusts遇到的ProxyError异常

Python request代理错误提示“HTTPSConnectionPool, Cannot connect to proxy, no such file or directory”

分享技术,记录思考和感悟 1522

UVA10494 If We Were a Child Again【大数除法】

“Oooooooooooooooh! &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;If I could do the easy mathematics like my school days!! &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;I can guarantee, that I’d not make any mistake this time!!” &

海岛Blog 599

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

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

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

UVA 10494 If We Were a Child Again(大数)

E - If We Were a Child Again Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu Submit Status Practice UVA 10494 Appoint description:  Luke  (2014-01-22)System Crawler  (

hahahaha 660

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

If We Were a Child Again(大数除法、模除)

题目链接:UVA 10494 大数除法、模除的模板题,直接上代码。 #include <iostream> #include <cstdio> #include <cstring> using namespace std; const int N=1024; char s[N],ans[N]; int main() { int len; l...

Ai_Mijie的博客 230

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

uva 10494 If We Were a Child Again(高精度与低精度求模和商)

If We Were a Child Again Input: standard input Output: standard output Time Limit: 7 seconds   “Oooooooooooooooh! If I could do the easy mathematics like my school days!! I can guarante

不慌不忙、不急不躁 1488

UVA 10494 - If We Were a Child Again(大数与整型相除取整和取余)

这道题让选手模拟相除和取余的过程,由于除数为整型,使得这道题的难度大大减小。要注意在模拟取余和相处的时候,中间的临时数会超过整型范围。       提供一个数据:21474836447 / 2147483647 #include #include // 大数字符串str与整型x相除,商赋给str void myDiv(char str[], int x) { int b

zcube的技术博客 2165

Uva 10494 If We Were a Child Again(高精度相除)

Problem C If We Were a Child Again Input: standard input Output: standard output Time Limit: 7 seconds   “Oooooooooooooooh! If I could do the easy mathematics like my school days!!

小G的ACM之路 1036

UVA - 10494 If We Were a Child Again

Problem C If We Were a Child Again Input: standard input Output: standard output Time Limit: 7 seconds   “Oooooooooooooooh! If I could do the easy mathematics like my school days!!

七夜 650

UVA 10494 If We Were a Child Again 高精度除法简单版

这道题和之前三道高精度的题一起挂的吧,但是隔了两天才来

Gatevin的专栏 1165

UVA10494 If We Were a Child Again

yiyi : 看了题目,以为整数只要用int 来存就够了,谁知道交了好几遍都不可以ac,后来把数据改成long类型的才可以,还是不是很懂什么时候会溢出,好坑,不开心!!! “Oooooooooooooooh! If I could do the easy mathematics like my school days!! I can guarantee, t

哈希的博客 456

UVa UVa 10494 - If We Were a Child Again

/* coder: ACboy date: 2010-3-3 result: 1AC description: UVa 10494 - If We Were a Child Again*/#include using namespace std;int const MAXN = 800;class BigNumber{public: i

个人独立博客http://www.acb0y.cn/ 1226

(高精度运算4.7.27)UVA 10494 If We Were a Child Again(大数除法&&大数取余)

package com.njupt.acm; import java.math.BigInteger; import java.util.Scanner; public class UVA_10494 { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); whi

黄俊东的专栏 1543

UVa 10494 - If We Were a Child Again

传送门 高精度水题

一只冰熊 1395

UVA 10494 If We Were a Child Again

java解决除法和取余。输入两个数,中间为除号或取余号,输出结果。 import java.util.*; import java.math.*; public class Main { public static void main(String[] args){ Scanner cin = new Scanner(System.in); BigInteger a, b

DotACM 662
上一篇: UVA 748 - Exponentiation
下一篇: UVA 113 - Power of Cryptography(数学)
coco430
博客等级 码龄14年 9粉丝 107原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值
⌂ 换网址