Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:为什么用递推不对呀~~Runtime Error

Posted by wenfengmtd at 2015-04-12 01:47:53 on Problem 1942
In Reply To:为什么用递推不对呀~~Runtime Error Posted by:liche717 at 2015-04-08 21:34:30
> #include <iostream>
> 
> using namespace std;
> long long f(long long n,long long m)
> {
>     if(n==0||m==0)
>         return 1;
>     if(n!=0&&m!=0) return f(n-1,m)+f(n,m-1);
> }
> int main()
> {
>     long long n,m;
>     while(cin>>n>>m)
>     {
>         if(n==0&&m==0)
>             break;
>         else cout<<f(n,m)<<endl;
>     }
>     return 0;
> }
测试数据里面有很大的数,导致申请内存时会溢出。我之前也是像你这样做的,老是C++是RE, G++时WA。这道题递推会超时

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator