问题 K: A/B Problem
题目描述

输入
输出
样例输入
110 / 100
99 % 10
2147483647 / 2147483647
2147483646 % 2147483647
样例输出
1
9
1
2147483646
1 #include<stdio.h>
2 #include<string.h>
3 char a[100000];
4 int c[100000],d[100000],s[100000];
5 int main() {
6 char ni;
7 int b;
8 while(scanf("%s %c %d",a,&ni,&b)!=-1) {
9 memset(c,0,sizeof(c));
10 memset(s,0,sizeof(s));
11 int l,k;
12 l=strlen(a);
13 int p=0;
14 for(int i=0; i<l; i++) {
15 c[p++]=a[i]-48;
16 }
17 if(ni=='/') {
18 if(b==0)
19 printf("0\n");
20 else {
21 if(a=="0")
22 printf("0\n");
23 else {
24 // if(b==0)
25 // printf("0\n");
26 // else {
27 int j=0;
28 int y=0;
29 int haha=0;
30 for(int i=0; i<l; i++) {
31 int sum=c[i]+y*10;
32 int x=sum/b;
33 y=sum%b;
34 if(x||y) {
35 haha=-1;
36 s[j++]=x;
37 }
38 }
39 if(haha==0) {
40 printf("0\n");
41 }
42 else {
43 for(int i=0; i<j; i++) {
44 printf("%d",s[i]);
45 }
46 printf("\n");
47 }
48 // }
49 }
50 }
51 }
52 if(ni=='%') {
53 if(b==0)
54 printf("%s\n",a);
55 else {
56 int sum=0;
57 for(int i=0; i<l; i++) {
58 sum=sum*10+(c[i]);
59 sum=sum%b;
60 }
61 printf("%d\n",sum);
62 }
63 }
64 }
65 return 0;
66 }
问题 K: A/B Problem的更多相关文章
- HDU 5832 A water problem(某水题)
p.MsoNormal { margin: 0pt; margin-bottom: .0001pt; text-align: justify; font-family: Calibri; font-s ...
- hdu 4217 Data Structure? 树状数组求第K小
Data Structure? Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) ...
- hdu-5686 Problem B(斐波那契数列)
题目链接: Problem B Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) ...
- 2014年亚洲区域赛北京赛区现场赛A,D,H,I,K题解(hdu5112,5115,5119,5220,5122)
转载请注明出处: http://www.cnblogs.com/fraud/ ——by fraud 下午在HDU上打了一下今年北京区域赛的重现,过了5题,看来单挑只能拿拿铜牌,呜呜. ...
- [HDU 1016]--Prime Ring Problem(回溯)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1016 Prime Ring Problem Time Limit: 4000/2000 MS (Jav ...
- HDU 5726 GCD 区间GCD=k的个数
GCD Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submis ...
- hduoj 1002 A + B Problem II
原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=1002 题目描述如下: A + B Problem II Time Limit: 2000/1000 M ...
- hdu 3861 The King’s Problem trajan缩点+二分图匹配
The King’s Problem Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Other ...
- HDU 6343 - Problem L. Graph Theory Homework - [(伪装成图论题的)简单数学题]
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6343 Time Limit: 2000/1000 MS (Java/Others) Memory Li ...
随机推荐
- 【Azure Developer】Azure Automation 自动化账号生成的时候怎么生成连接 与证书 (Connection & Certificate)
Azure Automation :The Azure Automation service provides a highly reliable and scalable workflow exec ...
- 终端进程启动失败: shell 可执行文件“C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe”的路径不存在。
因为某些原因重新安装1了vscode 和node 遇到了两个棘手的问题 ctrl + ~ 打开终端提示 " 终端进程启动失败: shell 可执行文件"C:\Windows\S ...
- 易华录 X ShardingSphere|葫芦 App 后台数据处理的逻辑捷径
"ShardingSphere 大大简化了分库分表的开发和维护工作,对于业务的快速上线起到了非常大的支撑作用,保守估计 ShardingSphere 至少为我们节省了 4 个月的研发成本.& ...
- 2020.10.30--vj个人赛补题
D - D CodeForces - 743A Vladik is a competitive programmer. This year he is going to win the Interna ...
- C++ 与 Visual Studio 2019 和 WSL(二)
终端 A more integrated terminal experience | Visual Studio Blog (microsoft.com) Say hello to the new V ...
- 这部分布式事务开山之作,凭啥第一天预售就拿下当当新书榜No.1?
大家好,我是冰河~~ 今天,咱们就暂时不聊[精通高并发系列]了,今天插播一下分布式事务,为啥?因为冰河联合猫大人共同创作的分布式事务领域的开山之作--<深入理解分布式事务:原理与实战>一书 ...
- K8s容器存储接口(CSI)介绍
Container Storage Interface是由来自Kubernetes.Mesos.Docker等社区member联合制定的一个行业标准接口规范,旨在将任意存储系统暴露给容器化应用程序. ...
- SpringCloud 2020.0.4 系列之服务降级
1. 概述 老话说的好:做人要正直,做事要正派,胸怀坦荡.光明磊落,才会赢得他人的信赖与尊敬. 言归正传,之前聊了服务间通信的组件 Feign,今天我们来聊聊服务降级. 服务降级简单的理解就是给一个备 ...
- 六个好习惯让你的PCB设计更优
PCB layout工程师每天对着板子成千上万条走线,各种各样的封装,重复着拉线的工作,也许很多人会觉得是很枯燥无聊的工作内容.看似软件操作搬运工,其实设计人员在过程中要在各种设计规则之间做取舍,兼顾 ...
- Exynos4412 中断处理流程详解
Linux 中,当外设触发中断后,大体处理流程如下: a -- 具体CPU architecture相关的模块会进行现场保护,然后调用machine driver对应的中断处理handler; b - ...