• poj1140


    模拟

    View Code
    #include <iostream>
    #include
    <cstdlib>
    #include
    <cstring>
    #include
    <cstdio>
    using namespace std;

    #define maxn 1005

    int n, m;
    int pos[maxn];

    void work()
    {
    int a = n;
    int b = m;
    int cnt = 1;
    int i = 1;
    pos[a]
    = 0;
    putchar(
    '.');
    while (true)
    {
    int temp = a * 10 / b;
    a
    = a * 10 % b;
    if (cnt % 50 == 0)
    putchar(
    '\n');
    putchar(temp
    + '0');
    cnt
    ++;
    if (pos[a] == -1)
    pos[a]
    = i;
    else
    {
    printf(
    "\nThe last %d digits repeat forever.\n", i - pos[a]);
    return;
    }
    if (a == 0)
    {
    printf(
    "\nThis expansion terminates.\n");
    return;
    }
    i
    ++;
    }
    }

    int main()
    {
    //freopen("t.txt", "r", stdin);
    while (scanf("%d%d", &n, &m), n | m)
    {
    memset(pos,
    -1, sizeof(pos));
    work();
    }
    return 0;
    }

  • 相关阅读:
    Java杂项
    JFrog Artifactory
    TestNG+Selenium
    Linux杂项
    Java
    Spring Boot
    学习ThinkPHP第一天
    linux下文件解压
    php中require_once与include_once的区别
    ubuntu下的wps office for linux
  • 原文地址:https://www.cnblogs.com/rainydays/p/2183113.html
Copyright © 2020-2023  润新知