UVA 10494 (13.08.02)
思路: 采取一种, 边取余边取整的方法, 让这题变的简单许多~
#include<stdio.h>
#include<string.h> int main() {
long long mod;
long long k, tmp;
int len;
int ans[10010];
char num[10010], ch[2];
while(scanf("%s%s%lld", num, ch, &mod) != EOF) {
len = strlen(num);
k = 0;
tmp = 0;
memset(ans, 0, sizeof(ans));
for(int i = 0; i < len; i++) {
tmp = tmp * 10 + num[i] - '0';
ans[k++] = tmp / mod; //此步导致ans有前导0, 后续要判断
tmp = tmp % mod;
}
if(ch[0] == '/') {
int pos;
for(pos = 0; pos < 10010; pos++)
if(ans[pos])
break; //从头判起, 直到第一个不为0的位置
if(pos == 10010)
printf("0");
else
for(int i = pos; i < k; i++)
printf("%d", ans[i]);
printf("\n");
}
else
printf("%lld\n", tmp);
}
return 0;
}
UVA 10494 (13.08.02)的更多相关文章
- UVA 465 (13.08.02)
Overflow Write a program that reads an expression consisting of twonon-negative integer and an ope ...
- UVA 424 (13.08.02)
Integer Inquiry One of the first users of BIT's new supercomputer was Chip Diller. Heextended his ...
- UVA 10106 (13.08.02)
Product The Problem The problem is to multiply two integers X, Y. (0<=X,Y<10250) The Input T ...
- UVA 10194 (13.08.05)
:W Problem A: Football (aka Soccer) The Problem Football the most popular sport in the world (ameri ...
- UVA 253 (13.08.06)
Cube painting We have a machine for painting cubes. It is supplied withthree different colors: blu ...
- UVA 573 (13.08.06)
The Snail A snail is at the bottom of a 6-foot well and wants to climb to the top.The snail can cl ...
- UVA 10499 (13.08.06)
Problem H The Land of Justice Input: standard input Output: standard output Time Limit: 4 seconds In ...
- UVA 10025 (13.08.06)
The ? 1 ? 2 ? ... ? n = k problem Theproblem Given the following formula, one can set operators '+ ...
- UVA 536 (13.08.17)
Tree Recovery Little Valentine liked playing with binary trees very much. Her favoritegame was con ...
随机推荐
- 通过html5的range属性动态改变图片的大小
range属性已经是很成熟的属性了,我们可以使用这个属性进行动态调整图片的宽度,其中原理在于通过不断获取range的值,并赋予给所需要的图片,进而达到动态改变图片的效果.下面贴出具体的代码,主要参照了 ...
- Java OOP考试错题分析
解析: A.ArrayList 可以存储NULL值,也可以存储重复的值,对集合没有任何影响. B.一旦实例化不可改变自身大小,这是数组的特性.集合的容量是自身扩容的. C.ArrayList可以存 ...
- 导出文本、表格、图像到PDF格式文件中(学习整理)
1.测试例子: 需要导入的外部jar包: 相关API http://www.coderanch.com/how-to/javadoc/itext-2.1.7/com/lowagie/text/pack ...
- ubuntu1404下Apache2.4错误日志error.log路径位置
首先打开/etc/apache2路径下的apache2.conf文件,找到ErrorLog如下 ErrorLog ${APACHE_LOG_DIR}/error.log 这里{APACHE_LOG_D ...
- 如何在本地安装测试ECSHOP 转载
如何在本地安装测试ECSHOP 如何在本地(自己的电脑)上先安装ECShop 一.创建PHP环境 1.下载AppServ 因为ECShop在线网上商店系统是用PHP语言开发的,所以,在本地架设网店之前 ...
- shell命令:echo命令详解
功能说明:显示文字. 语 法:echo [-ne][字符串] / echo [--help][--version] 补充说明:echo会将输入的字符串送往标准输出.输出的字符串间以空白字符隔开, 并在 ...
- sass用法
可能刚开始我们学习前端的时候都习惯用html+css.来做网页,但是我们发现css有很多重复的代码或者是你要改里面的图片或者文字还有去诶个的找很麻烦,所以我们就用sass来简化它. 首先我们需要安装一 ...
- Spring面试笔记
1. Spring工作机制及为什么要用?Spring 是一个开源框架,是为了解决企业应用程序开发复杂性而创建的.Spring既是一个AOP框架,也是一IOC容器.SpringFramework的组成: ...
- 1、C# MVC学习之NVelocity基本使用
小白一个,刚刚开始学,大神不要笑话...... NVelocity是一个很容易上手的框架,从它开始学习,可以循序渐进 首先,创建空web应用程序,新建一般处理程序 Login2.ashx 然后,引入N ...
- [BZOJ 1081] [SCOI2005] 超级格雷码 【找规律】
题目链接:BZOJ - 1081 备注:此题BZOJ上貌似没有 spj ,要把一般顺序的每个格雷码倒着输出...比如 0102 输出为 2010 题目分析 就是按照 Gray 码的生成方法写前几个出来 ...