No one has voted on any posts yet. Votes from other community members are used to determine a member's reputation amongst their peers.
The question is Let's consider a triangle of numbers in which a number appears in the first line, two numbers appear in the second line, three in the third line, etc. Develop a program which will compute the largest of the sums of numbers that appear on the paths starting … |
|
I wrote a code to get factorial for a number uptil 100. The problem i have is that i have to display the array it is sstored in a single output. So i cant use for statement and print each element. [CODE=CPP]#include<iostream> #include<cstdio> using namespace std; int main() { int … |
|
[CODE=CPP]#include<iostream> #include<cstdio> #include<stack> using namespace std; bool opgreater(char ,char); bool opgreater(char a ,char b) { if(a=='^') return 1; else return((a=='*' || a== '/')>=(b=='*' || b=='/')); } int main() { int n; scanf("%d",&n); while (n--) { stack<char> exp; string initial; string final=""; int i=0; bool x; char temp,temp2; getline(cin,initial,'\n'); initial+='\0'; while(initial[i]!='\0') … |
|
I am having a problem in implementing of sieve of eratosthenes.. please check the code and tell me the error [CODE] #include<iostream> #include<cstdio> using namespace std; int main() { int i,j; long array[100001]; int count=0; for(i=1;i<100001;i++) { array[i]=i; } for(i=2;i<100001;i++) { if(array[i]!=0) { cout<<""<<array[i]<<endl; int j=0; j=i*i; while(j<100001) { array[j]=0; … |
|
I was coding for a particular problem whose time limit was 2 seconds.. The no. of input was max 300000. Simply taking in the number using cin and outputting the same number with cout will take more than 2 seconds. Any ideas on how to increase efficiency?? |
|
I wanted to know an efficient algorithm to calculate the product of divisors.. My brute force method is giving me a Time limit exceeded. |
|
I was trying to find the number of zeroes in a factorial of a number. The time limit was 2 sec. Max number of test cases being 100000 my code is as follows [code=cpp] #include<iostream> #include<cstdio> int five(int number); int two(int number); using namespace std; main() { int num; int … |