Hdu2522 a simple problem [simulation]

Source: Internet
Author: User

A simple problemtime limit: 4000/2000 MS (Java/others) memory limit: 32768/32768 K (Java/Others) Total submission (s): 3133 accepted submission (s): 1144

Problem descriptionzty is obsessed with mathematical problems .. One day, yifenfei had a math problem and asked him to answer 1/N. But zty cannot answer ^_^. Ask everyone to program and help him.
 
The integer T in the first line of input, indicating the number of test groups. Followed by T rows, each row has an integer N (1 <=| n |<= 10 ^ 5 ).
Output 1/n. (It is a circular decimal number and only outputs the first circular section ).
Sample Input
4237168
 
Sample output
0.50.30.1428570.005952380
 
Authoryifenfei
Sourcehdu 2008-10 Programming Contest

#include <stdio.h>#include <string.h>#define maxn 100002bool vis[maxn];int main(){    int n, i, t, m;    scanf("%d", &t);    while(t--){        scanf("%d", &n);        if(n < 0){            printf("-"); n = -n;        }        if(n == 1){            printf("1\n"); continue;        }                memset(vis, 0, sizeof(bool) * n);        printf("0."); m = 1; vis[0] = 1;        while(!vis[m]){            vis[m] = 1; m *= 10;            printf("%d", m / n);            m %= n;        }        printf("\n");    }    return 0;}


Hdu2522 a simple problem [simulation]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.