10450  World Cup Noise
Moderator: Board moderators

 Experienced poster
 Posts: 192
 Joined: Sat Nov 30, 2002 5:14 am
10450 why WA?
i have tried my ways but still got WA.
i know someone use long long but i still got WA
i here use double and precision set to zero.
but still failed, who can help me?
Here is my code.

#include <iostream.h>
#define Max 51
double S[Max]={2,3};
void Cal()
{
int i;
for(i=2;i<Max;i++)
S=S[i1]+S[i2];
}
void main()
{
Cal();
int n;
cin>>n;
while(n)
{
int i;
cin>>i;
cout<<"Scenario #"<<i<<":"<<endl;
cout.setf(ios::fixed);
cout.precision(0);
cout<<S[i1]<<endl<<endl;
}
}
i know someone use long long but i still got WA
i here use double and precision set to zero.
but still failed, who can help me?
Here is my code.

#include <iostream.h>
#define Max 51
double S[Max]={2,3};
void Cal()
{
int i;
for(i=2;i<Max;i++)
S=S[i1]+S[i2];
}
void main()
{
Cal();
int n;
cin>>n;
while(n)
{
int i;
cin>>i;
cout<<"Scenario #"<<i<<":"<<endl;
cout.setf(ios::fixed);
cout.precision(0);
cout<<S[i1]<<endl<<endl;
}
}

 New poster
 Posts: 1
 Joined: Tue Aug 20, 2002 5:57 pm
 Location: Bangladesh
It's nice to see that so many various problems can be solved by Fibonacci Numbers!!
If there are more such prob. in ACM, tell me!!!
Btw, when n = 50, the answer should contain 11 digits.
If there are more such prob. in ACM, tell me!!!
Btw, when n = 50, the answer should contain 11 digits.
7th Contest of Newbies
Date: December 31st, 2011 (Saturday)
Time: 12:00  16:00 (UTC)
URL: http://uva.onlinejudge.org
Date: December 31st, 2011 (Saturday)
Time: 12:00  16:00 (UTC)
URL: http://uva.onlinejudge.org
10450 WA  why?
Hey guys, I did the World Cup problem and did figure out why the answer was a Fibonacci number. So i coded this...
[cpp]
#include <iostream>
#include <math.h>
using namespace std;
long long fibo(int x)
{
return (long long)((pow((1+sqrt(5.))/2,x)pow((1sqrt(5.))/2,x))/sqrt(5.));
}
int main()
{
int x,i=1;
while (cin >> x)
cout << "Scenario #" << i++ << endl << fibo(x+2) << endl << endl;
return 0;
}[/cpp]
But i get WA?! Yes there is a formula for fibonacci's number and it does work...anyone help please?[/cpp]
[cpp]
#include <iostream>
#include <math.h>
using namespace std;
long long fibo(int x)
{
return (long long)((pow((1+sqrt(5.))/2,x)pow((1sqrt(5.))/2,x))/sqrt(5.));
}
int main()
{
int x,i=1;
while (cin >> x)
cout << "Scenario #" << i++ << endl << fibo(x+2) << endl << endl;
return 0;
}[/cpp]
But i get WA?! Yes there is a formula for fibonacci's number and it does work...anyone help please?[/cpp]
 alu_mathics
 Learning poster
 Posts: 55
 Joined: Sat Jan 24, 2004 9:30 pm
 Location: Chittagong
 Contact:
 J&Jewel
 New poster
 Posts: 50
 Joined: Thu Jul 31, 2003 10:43 am
 Location: Daffodil University,Dhaka,Bangladesh
 Contact:
Hello friends....
I want to solve this problem....it was only the trick of fibonacci num...
I save them in an array. and compare each of the input of above....and all same....
But my program get WA why....?
I cant understand I use double too...
Here is my code.....Please Checked the code....
I want to solve this problem....it was only the trick of fibonacci num...
I save them in an array. and compare each of the input of above....and all same....
But my program get WA why....?
I cant understand I use double too...
Here is my code.....Please Checked the code....
Code: Select all
#include<stdio.h>
double array[60];
void fibonacci(long a)
{
long i;
array[0]=0;
array[1]=1;
for(i=2;i<=a;i++)
{
array[i]=array[i1]+array[i2];
}
}
int main()
{
int input,n,i;
//freopen("d:\\10450.txt","r",stdin);
fibonacci(55);
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&input);
if(input==0)
printf("0\n");
else
printf("%0.lf\n",array[input+2]);
}
return 0;
}
I hate Wrong Answer!

 New poster
 Posts: 30
 Joined: Mon Jun 19, 2006 10:37 pm
 Contact:
I am getting damn stupid WA ??..
plz help me out...
Code: Select all
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int x,i=1;
int n;
cin>>n;
while (i<=n){
cin >> x;
long long int a,b,c;
a=1;b=1;
for (int j=3;j<=x+2;j++)
{
int t;
t=a;
a=a+b;
b=t;
}
cout << "Scenario #" << i++ <<":"<< endl << a << endl << endl;
}
return 0;
}
win

 Learning poster
 Posts: 54
 Joined: Mon Jan 02, 2006 3:06 am
 Location: Dhaka,Bangladesh
 Contact:
you need to change following things:
in the above part declare j and t as long long.
moreover, for
but yours one gives 1.
hope you'll get AC
Code: Select all
for (int j=3;j<=x+2;j++)
{
int t;
t=a;
a=a+b;
b=t;
}
moreover, for
Code: Select all
x=0
a=0
hope you'll get AC
Sanjana

 New poster
 Posts: 30
 Joined: Mon Jun 19, 2006 10:37 pm
 Contact:
Re: 10450  World Cup Noise
Code: Select all
Accepted
Last edited by Obaida on Sat Nov 01, 2008 6:56 am, edited 1 time in total.
try_try_try_try_&&&_try@try.com
This may be the address of success.
This may be the address of success.
Re: 10450  World Cup Noise
Just think that how many times the recursive calls being used? Say, for n = 6 you have to calculate for both 5 and 4, again for 5 you have to calculate both 4 and 3. 4 is calculated twice. So, if you think a while you will find that the number of calls are increasing exponentially.
Ami ekhono shopno dekhi...
HomePage
HomePage
Re: 10450  World Cup Noise
Thanks jan bi.
i got acc.
i got acc.
try_try_try_try_&&&_try@try.com
This may be the address of success.
This may be the address of success.
 newton
 Experienced poster
 Posts: 162
 Joined: Thu Jul 13, 2006 7:07 am
 Location: Campus Area. Dhaka.Bangladesh
 Contact:
Re: 10450  World Cup Noise
Its a simple Java code
but ONLINEJUDGE says me RE!!
why can u find plz.
but ONLINEJUDGE says me RE!!
why can u find plz.
Code: Select all
import java.util.*;
import java.io.*;
import java.math.BigInteger;
class WorldCup{
WorldCup(){};
public static void main(String args[]){
int i,n,num;
BigInteger B[] = new BigInteger[55];
Scanner sc = new Scanner(System.in);
B[0] = new BigInteger("1");
B[1] = new BigInteger("2");
for(i = 2; i< 55; i++){
B[i] = B[i1].add(B[i2]);
}
n = sc.nextInt();
for(i = 1; i <= n; i++){
num = sc.nextInt();
System.out.println("Scenario #"+i+":\n"+B[num]);
System.out.println("");
}
}
}
http://www.newton.0fees.net is enough!