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]