Question Link: https://www.codechef.com/problems/CHEFPDIG
I am having problem to take input that large number of size10^100000, otherwise i can do it. Please tell me how to take that much large number into consideration.
Actually this is what i was doing. i was using getche(although its not a STL function) and then counting the frequency of the digits. But, the if statement at the last of the program is not executing. Please suggest any better method to take input the number.
#include<stdio.h> #include<conio.h> int main() { char p; int i,c=0; static int arr[10]; do { p=getche(); //using getche to take input that large no. if(p!='\n') arr[p]++; } while(p!='\r'); //out of the loop after i press enter if(arr[6]>=1) { . . . . }
Asked by: Samrat_De on April 7, 2019, 6:34 p.m. Last updated on April 7, 2019, 6:34 p.m.
It is not necessary to take input as an intger.So if you are using c++ then input the number as string and then use that string for further operation.
#include <bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);cin.tie(NULL); //include this line for fast input/output in c++
int t;
cin>>t; //use cin to take input and cout for output
string n;
while(t--)
{
cin>>n;
//your code
}
return 0;
}