Page 1 of 2
10696 - f91
Posted: Thu Dec 15, 2005 10:30 am
by abhi
i get WA for this problem.
for all test cases <=100 i get the ans as 91 and for>=101 i get n-10 as ans
any test cases ?????
Posted: Thu Dec 15, 2005 4:29 pm
by mamun
Your idea is alright. Check your output format and you need long for this problem.
Why my program use so many memory?
Posted: Thu Jun 15, 2006 12:26 pm
by Zaspire
Why my program use 440

memory?(10696)
#include <iostream>
int main()
{
int n,k;
std::cin>>n;
while (n!=0)
{
if (n<=100) k=91;
else k=n-10;
std::cout<<"f91("<<n<<") = "<<k<<std::endl;
std::cin>>n;
}
return 0;
}
Re: Why my program use so many memory?
Posted: Sun Jun 03, 2007 2:00 pm
by Deny Sutani
Zaspire wrote:Why my program use 440

memory?(10696)
#include <iostream>
int main()
{
int n,k;
std::cin>>n;
while (n!=0)
{
if (n<=100) std::cout<<"f91("<<n<<") = "<<91<<std::endl;
else std::cout<<"f91("<<n<<") = "<<n-10<<std::endl;
std::cin>>n;
}
return 0;
}
Maybe that one will be better. My code only use 396, but still not good at all

Posted: Sun Jun 03, 2007 6:55 pm
by yiuyuho
Probably an error in the memory calculation, you can pay no attention to it if you get AC.
I remember a few years back the memory calculation are just totally off for some problems, I can allocate a 2M int array and it says I use 64KB....
But I think they've fixed a lot of those already and most are accurate. Still, can have bugs here.
Re: 10696 - f91
Posted: Sat Apr 04, 2009 8:19 pm
by ahmed
I am getting TLE in this problem.But I don't know why.Can anyone please help me?
Code: Select all
#include<iostream>
using namespace std;
int f91(int n)
{
if(n<=100)
{
return f91(f91(n+11));
}
else if(n>=101)
return n-10;
}
int main(void)
{
int n;
while(cin>>n)
{
if(n==0)
return 0;
cout<<"f91("<<n<<") = "<<f91(n)<<endl;
}
return 0;
}
Re: 10696 - f91
Posted: Sun Apr 05, 2009 8:19 pm
by Obaida
Replace the input/output by
scanf and
printf 
you can directly use this
for all test cases <=100 i get the ans as 91 and for>=101 i get n-10 as ans by an if. No need for this f91 function.
Re: 10696 - f91
Posted: Tue Jan 03, 2012 7:47 pm
by wasifhossain
ahmed wrote:I am getting TLE in this problem.But I don't know why.Can anyone please help me?
Code: Select all
#include<iostream>
using namespace std;
int f91(int n)
{
if(n<=100)
{
return f91(f91(n+11));
}
else if(n>=101)
return n-10;
}
int main(void)
{
int n;
while(cin>>n)
{
if(n==0)
return 0;
cout<<"f91("<<n<<") = "<<f91(n)<<endl;
}
return 0;
}
Yours One is a Naive Straight-forward approach. Try to find the TRICK inside the recursive case by simulating some small cases(N <= 100) using your existing solution above. You'll find a simple number again & again! Now the rest is left upon you. Enjoy!
UVA Problem ID :10696(Why I am getting Presentation error?)
Posted: Thu Jun 14, 2012 10:09 pm
by Enayet Kabir
Here is my source code:
=========================
#include<stdio.h>
long N,result;
long int Mc(long int );
int main()
{
while(scanf("%ld",&N)==1)
{
if(N==0) break;
else
{
result=Mc(N);
printf("f91(%ld) = %ld\n",N,result);
}
}
return 0;
}
long Mc(long int N)
{
if(N>=101)
return (N-10);
else
return (Mc(Mc(N+11)));
}
Re: UVA Problem ID :10696(Why I am getting Presentation erro
Posted: Fri Jun 15, 2012 9:04 pm
by brianfry713
That is AC code.
Re: 10696 - f91
Posted: Tue Jun 26, 2012 10:59 pm
by sith
Hello
I've got WA, Why?
Here is my solution
Re: 10696 - f91
Posted: Tue Jun 26, 2012 11:56 pm
by brianfry713
Don't print the runtime at the end.
Re: 10696 - f91
Posted: Wed Jun 27, 2012 8:13 pm
by sith
Thanks, my stupid mistake

Re: 10696 - f91
Posted: Tue Jul 23, 2013 10:14 am
by raihan_sust5
i didn't get that how caluculate the f91 for N<= 100......anyone help please..
Re: 10696 - f91
Posted: Wed Jul 24, 2013 3:32 am
by brianfry713
If N <= 100 then f91(N) = 91.