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 ...
随机推荐
- 【转】Spring.NET学习笔记——目录
目录 前言 Spring.NET学习笔记——前言 第一阶段:控制反转与依赖注入IoC&DI Spring.NET学习笔记1——控制反转(基础篇) Level 200 Spring.NET学习笔 ...
- hdu 1788 Chinese remainder theorem again(最小公倍数)
Problem Description 我知道部分同学最近在看中国剩余定理,就这个定理本身,还是比较简单的: 假设m1,m2,-,mk两两互素,则下面同余方程组: x≡a1(mod m1) x≡a2( ...
- ACM hdu 1019 Least Common Multiple
Problem Description The least common multiple (LCM) of a set of positive integers is the smallest po ...
- Binary Tree Inorder Traversal 解题思路 ×
问题: 非递归中序遍历二叉树 思路: 1.大循环,判断节点是否为空,栈是否为空 2.不为空:点进栈,向左走 3.为空:为空,出栈,读取值,向右走
- mongoengine教程1
mongoengine安装过程,建议先安装好pip,pip是不Python不错的安装包管理器,安装命令:pip install mongoengine. mongoengine是mongodb的pyt ...
- java子类实例初始化过程
子类的实例化主要分为两个步骤: <1>.类相关静态内容 初始化: *先父类再子类: 1.父类的static属性: 2.父类的static块: 3.子类的static属性: 4 ...
- C#委托(Delegate)学习日记
在.NET平台下,委托类型用来定义和响应应用程序中的回调.事实上,.NET委托类型是一个类型安全的对象,指向可以以后调用的其他方法.和传统的C++函数指针不同,.NET委托是内置支持多路广播和异步方法 ...
- [topcoder]UnsealTheSafe
http://community.topcoder.com/stat?c=problem_statement&pm=4471&rd=10711 这题果然是道简单题,图+DP.拿道题便觉 ...
- python模块与包加载机制
模块的搜索路径: When a module named spam is imported, the interpreter searches for a file named spam.py in ...
- 转---在ASP.NET MVC中实现登录后回到原先的界面
有这样的一个需求:提交表单,如果用户没有登录,就跳转到登录页,登录后,跳转到原先表单提交这个页面,而且需要保持提交表单界面的数据. 提交表单的页面是一个强类型视图页,如果不考虑需要保持提交表单界面的数 ...