/*
Solution 1/n;
Solution: Write an algorithm for outputting decimal places
Key point: how to process the decimal point loop output
Problem solving person: lingnichong
Solution time: 09:04:22
Problem-solving experience: the algorithm for outputting decimal places is not fully understood. Remember first
*/
A simple mathematical problem time limit: 3000 MS | memory limit: 65535 kb difficulty: 3
-
Description
-
ZYC recently fell in love with mathematics. One day, DJ came up with a math question to help him. Calculate 1/N, but ZYC cannot answer the question at one time. I hope everyone can help him with programming.
-
Input
-
The integer T in the first line indicates the number of test groups. Followed by T rows, each row has an integer N (1 <=| n |<= 10 ^ 5 ).
-
Output
-
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
-
Source
-
HDU
-
Uploaded
-
Pass this
# Include <stdio. h> # include <string. h> # define maxn 100000 + 10 char a [maxn]; int main () {int N, S, T; scanf ("% d", & S ); while (s --) {scanf ("% d", & N); If (n = 1 | n =-1) // the score, when N is 1, printf ("% d \ n", 1/n) is calculated directly; else {memset (A, 0, sizeof ()); // when n is 0, if (n <0) {n =-N; printf ("-0. ");} else printf (" 0. "); t = 1; while (A [T]! = 1 & T! = 0) // output decimal point {A [T] = 1; T * = 10; printf ("% d", T/N); T % = N ;} printf ("\ n") ;}} return 0 ;}
Nyoj 330 a simple mathematical problem]