Hello Programmers In this post, you will know how to solve the Approximately Codechef Solution. The Problem Code: APPROXApproximately Codechef SolutionOne more thing to add, don’t directly look for the solutions, first try to solve the problems of Codechef by yourself. If you find any difficulty after trying several times, then you can look for solutions.ProblemChef has recently learnt some new facts about the famous number π. For example, he was surprised that ordinary fractions are sometimes used to represent this number approximately. For example, 22/7, 355/113 or even 103993/33102.Soon, by calculating the value of 22/7 and 355/113 on paper Chef became quite disappointed because these values are not precise enough. For example, 22/7 differs in the third digit after the decimal point. So, these values are definitely should not be used for serious calculations.However, Chef doesn’t know anything about 103993/33102. This fraction is quite inconvenient to calculate on paper. Chef is curious how precise this value is. So he asks you to help him and to calculate the first K digits after the decimal point of such an approximation of π. He consider this ordinary fraction as infinite decimal fraction so formally he asks you to calculate this approximation truncated to the first K digits after the decimal point.InputThe first line of the input contains an integer T, denoting the number of test cases. The description of T test cases follows. The only line of each test case contains a single integer K.OutputFor each test case output a single line containing the value of 103993/33102 truncated to the first K digits after the decimal point. Note that for K = 0 you should output just “3” without decimal point (quotes are for clarity).Constraints0 ≤ K ≤ 1061 ≤ T ≤ 2000The sum of K over the input does not exceed 106ExampleSample Input 1 3 6 20Sample Output 1 3 3.141592 3.14159265301190260407Approximately CodeChef Solution in JAVAimport java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int T = sc.nextInt(); for (int tc = 0; tc < T; tc++) { int K = sc.nextInt(); System.out.println(solve(K)); } sc.close(); } static String solve(int K) { StringBuilder result = new StringBuilder(); int numerator = 103993; int denominator = 33102; for (int i = 0; i < K + 1; i++) { if (i == 1) { result.append("."); } result.append(numerator / denominator); numerator = numerator % denominator * 10; } return result.toString(); } } Approximately CodeChef Solution in CPP#include <iostream> #include<cmath> #include<iomanip> using namespace std; int main() { int t; cin>>t; while(t--){ int a=103993; int b=33102; int c=a%b; int k; cin>>k; c=c*10; cout<<3; if(k>0){ cout<<"."; while(k--){ cout<<c/b; c=(c%b)*10; } } cout<<endl; } return 0; } Approximately CodeChef Solution in Pythontc = int(input()) for _ in range(tc): k = int(input()) ans = '3' if(k == 0): print(ans) continue ans = ans + '.' num = 4687 den = 33102 for i in range(k): num *= 10 ans += str(num//den) num = num % den print(ans)Disclaimer: The above Problem (Approximately) is generated by CodeChef but the solution is provided by BrokenProgrammers. This tutorial is only for Educational and Learning purposes.Note:- I compile all programs, if there is any case program is not working and showing an error please let me know in the comment section. If you are using adblocker, please disable adblocker because some functions of the site may not work correctly.Next: Balsa For The Three Codechef Solution Post navigationYet Another Flipping Problem Codechef Solution Balsa For The Three Codechef Solution