点此连接到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. Linux的cat、more、less的区别

    cat命令功能用于显示整个文件的内容单独使用没有翻页功能因此经常和more命令搭配使用,cat命令还有就是将数个文件合并成一个文件的功能. more命令功能:让画面在显示满一页时暂停,此时可按空格健继 ...

  2. 关于正则表达式的转义 PHP

    如正则的函数 preg_replace($patern, $replacement, $content) 等等 其中如果 $content 中要替换 \ 成 /,必须在 $patern中写成 \\\\ ...

  3. 能用存储过程的DBHelper类

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.D ...

  4. video,source元素

    一,视频 <video src="../[再一次快乐结局]第15集.mp4" controls="controls" width="500&qu ...

  5. linux shell获取时间

    获得当天的日期 date +%Y-%m-%d 输出: 2011-07-28 将当前日期赋值给DATE变量DATE=$(date +%Y%m%d) 有时候我们需要使用今天之前或者往后的日期,这时可以使用 ...

  6. python for list generate content

    content = [ii for ii in range(50)] This can generate a list content

  7. 关于applicationx/www-form-urlencoded和multipart/form-data的描述

    在Form元素的语法中,EncType表明提交数据的格式 用 Enctype 属性指定将数据回发到服务器时浏览器使用的编码类型. 下边是说明: application/x-www-form-urlen ...

  8. tomcat发布静态网页

  9. vim脚本及配置

    ============set optional===========set nu         //显示行号                                        numb ...

  10. Uva_11762 Race to 1

    题目链接 题意: 给一个数n, 每次从小于等于n的素数里选一个P, 如果能被n整除, 那么就n就变成n / P. 问: n 变成1的期望. 思路: 设小于等于n的素数有p 个, 其中是n的约数的有g个 ...