点此连接到UVA10494

思路: 采取一种, 边取余边取整的方法, 让这题变的简单许多~

AC代码:

#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)的更多相关文章

  1. UVA 465 (13.08.02)

     Overflow  Write a program that reads an expression consisting of twonon-negative integer and an ope ...

  2. UVA 424 (13.08.02)

     Integer Inquiry  One of the first users of BIT's new supercomputer was Chip Diller. Heextended his ...

  3. UVA 10106 (13.08.02)

     Product  The Problem The problem is to multiply two integers X, Y. (0<=X,Y<10250) The Input T ...

  4. UVA 10194 (13.08.05)

    :W Problem A: Football (aka Soccer)  The Problem Football the most popular sport in the world (ameri ...

  5. UVA 253 (13.08.06)

     Cube painting  We have a machine for painting cubes. It is supplied withthree different colors: blu ...

  6. 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 ...

  7. UVA 10499 (13.08.06)

    Problem H The Land of Justice Input: standard input Output: standard output Time Limit: 4 seconds In ...

  8. UVA 10025 (13.08.06)

     The ? 1 ? 2 ? ... ? n = k problem  Theproblem Given the following formula, one can set operators '+ ...

  9. UVA 536 (13.08.17)

     Tree Recovery  Little Valentine liked playing with binary trees very much. Her favoritegame was con ...

随机推荐

  1. jQuery AJAX load() 方法

    jQuery load() 方法 jQuery load() 方法是简单但强大的 AJAX 方法. load() 方法从服务器加载数据,并把返回的数据放入被选元素中. 语法: $(selector). ...

  2. ie6常见的兼容性

    1.IE6怪异解析之padding与border算入宽高 原因:未加文档声明造成非盒模型解析 解决方法:加入文档声明<!doctype html> 2.IE6在块元素.左右浮动.设定mar ...

  3. URL 路由访问报错

    错误: 错误分析:    控制器的文件名命名有问题(index.php)    在TP中控制器命名规范(IndexController.class.php) 相信许多PHP开发者在使用ThinkPHP ...

  4. cmd 窗口的复制粘贴

    如下几种方法1.点击鼠标右键,选择标志,再点击左键拖动选择要复制的内容,然后回车即可复制被 选择的内容 2.点击鼠标右键,选择标志,再点击左键拖动选择要复制的内容,然后点击鼠标右键, 此时就把选择的内 ...

  5. smarty模板引擎原理解析

    //php 控制器文件 <?php//引入模板引擎文件include("20130304.php");$smarty =newTinySmarty();$qq_numbers ...

  6. The largest prime factor(最大质因数)

    1. 问题: The prime factors of 13195 are 5, 7, 13 and 29.What is the largest prime factor of the number ...

  7. servlet跳转jsp

    ackage com.monkey.servlet; import javax.servlet.*; import javax.servlet.http.*; import java.io.*; im ...

  8. 单元测试unit test,集成测试integration test和功能测试functional test的区别

    以下内容转自 https://codeutopia.net/blog/2015/04/11/what-are-unit-testing-integration-testing-and-function ...

  9. FutureTask源码解读

    import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; import java.ut ...

  10. 利用servlet做转发,实现js跨域解决同源问题

    做前端开发,避免不了跨域这个问题,跨域具体什么概念,不赘述,博客里太多.简单说下,我们用js发请求,不管post还是get,如果发请求的对象和当前web页面不在同一域名下,浏览器的同源策略会限制发请求 ...