标签:模拟
4 2 3 7 168
0.5 0.3 0.142857 0.005952380
代码:
#include <stdio.h> #include <string.h> #define M 100005 bool vis[M]; int main(){ int n, t; scanf("%d", &t); while(t --){ scanf("%d", &n); memset(vis, false, sizeof(vis)); if(n == 1||n == -1){ printf("%d\n", n); continue; } if(n < 0){ printf("-"); n = -n; } int pre = 1, mod = 1; printf("0."); while(1){ pre*=10; if(vis[mod]||mod == 0) break; vis[mod] = 1; mod = pre%n; printf("%d", pre/n); pre %= n; } printf("\n"); } return 0; }
hdoj 2522 A simple problem 【模拟】
标签:模拟
原文地址:http://blog.csdn.net/shengweisong/article/details/41014141