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

Windows11下QGIS 3.34.4安装Geo-SAM插件全流程(附RTX3060 CUDA12.0配置技巧) 本文详细介绍了在Windows 11系统中为QGIS 3.34.4安装和配置Geo-SAM插件的完整流程,特别针对RTX 3060显卡用户提供了CUDA 12.0与PyTorch环境的精准搭建方案。通过预编码与交互式分割两大核心步骤,该插件能显著提升遥感图像半自动标注的效率,降低硬件门槛,是地理信息处理领域融合AI技术的实用指南。 阅读详情

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;
}


Antlr4入门(二)基本概念解析 在上一章中(Antlr4入门(一)IDEA中Antlr的安装与使用),我们安装了Antlr,并编写运行了第一个程序“Hello world”。而在本章中,我们将学习语言类应用程序相关的重要过程、术语和数据结构。 一. 术语 语言(language)是由一系列有意义的语句组成,语句(sentence)由词组组成,词组(phrase)是由更小的子词组(subphrase)和词汇符号(vocabulary symbols)组成。 举个例子,英语就是一种语言,“Keep on going never gi. 阅读详情

相关推荐

H3C ACL的应用与配置1

SWHC1-acl-ipv4-adv-3000]rule 30 permit ip source 192.168.50.252 0 destination 192.168.70.252 0 //设置一条ID为30的过滤,允许源地址为 192.168.50.252 访问目的地址为192.168.70.252 的设备。高级ACL范围3000-3999:对源IP,目地IP,协议,端口号进行过滤。[SWHC1]acl number 3000 //创建高级ACL 3000。

weixin_41120428的博客 2425

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

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

敲代码的小潘的博客 631

SAP子公司财务账套配置实战:从公司代码到记账期间变式的关键步骤

本文详细介绍了为SAP子公司快速配置财务账套的实战步骤。通过复用母公司成熟配置,重点阐述了从创建公司代码、关联控制范围到分配记账期间变式的核心流程,帮助顾问在一两个小时内完成核心骨架搭建,实现高效集团财务管控。

cake8的博客 166

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 178

电路仿真软件PSIM简介

PSIM的基本使用操作...

qq_55203246的博客 7179

高精度模板

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

qq_52441682的博客 1065

信号系统核心概念:卷积、傅里叶变换与抽样定理的工程实践指南

信号与系统是理解现代电子、通信与数字处理技术的基石。其核心在于通过数学工具对物理世界进行建模与分析,其中卷积运算揭示了线性时不变系统对任意输入的响应可分解为冲激响应的叠加,这一原理极大提升了系统测试与分析的效率。而傅里叶变换则提供了从时域到频域的映射,将复杂的时域卷积运算转化为频域的简单乘法,是实现频谱分析、滤波设计的关键。抽样定理则架起了模拟与数字世界的桥梁,明确了无失真数字化的条件。这些基础理论共同构成了滤波器设计、音频处理、图像分析及通信系统等广泛工程应用的技术支柱。本文聚焦于卷积与傅里叶变换,结合冲

weixin_30788619的博客 629

UVa 10494 如果我们再回童年

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

buxizhizhou530的专栏 894

电拖笔记1电磁学基本知识与定律

电拖学习

qq458629839的博客 1133

YOLOv11涨点改进| CVPR 2026 | 全网独家首发、特征融合改进篇| 引入SRFusion 空间细化多级融合,含多种创新融合改进,涨点可直接发论文,适合裂缝图像检测,小目标检测任务高效涨点

🔥本文提出SRFusion空间细化多级融合模块,用于改进YOLOv11网络模型。该模块通过高分辨率特征引导低分辨率语义特征的融合,利用空间注意力机制对上采样后的特征进行加权细化,增强多尺度特征间的空间细节交互。SRFusion模块能够提升模型对目标区域的表达能力,有效改善小目标、密集目标及复杂背景场景下的检测效果,同时保持YOLOv11的高效性与实时检测性能。文章详细介绍了模块结构、实现原理、核心代码及在YOLOv11中的三种配置方法,为模型优化提供了创新解决方案。

Ai缝合怪、助力小伙伴高效发论文 148

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

Vue3 - 详细实现微信公众号H5网页内置浏览器中预览下载word文档(doc)、excel表格(xls)、ppt文稿、pdf文档等文件,微信内部直接打开预览和下载到本地教程,安卓苹果手机无差异兼容

vue3,nuxt3,微信公众号,h5,移动端,网页,网站,vue微信内置浏览器下载文件,下载文件,在微信浏览器里面实现下载任意文件,H5需要在微信浏览器中下载excel文件,实现网页在微信内置浏览器中下载文件详细教程,安卓点击下载会提示打开浏览器,后端返回流文件,如何解决无法下载文件,跳转至浏览器下载文件,发送到电脑微信,安卓,苹果,手机系统,微信H5页面,vue3微信公众号H5网站,内置浏览器下载文档,如何在微信浏览器中预览office文件,word文档,excel文档,pdf文档,ppt文档,offi

🏆 前端领域优质创作者 1万+

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 597

计算机控制技术及应用

《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

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 659

pscad IEEE标准系统搭建说明

pscad IEEE标准系统搭建说明,包含典型的IEEE 9节点、14节点、30节点、39节点和118节点系统。内含标准测试系统的原始数据和潮流结果。

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的博客 229

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

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

不慌不忙、不急不躁 1486

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

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

zcube的技术博客 2164

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之路 1033

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!!

七夜 649

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

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

Gatevin的专栏 1164

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

哈希的博客 455

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/ 1224

(高精度运算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

传送门 高精度水题

一只冰熊 1394

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、付费专栏及课程。

余额充值