ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1012. K-based Numbers. Version 2

WHY WA#6?HERE IS MY CODE!!THANK!!!!
Posted by CHIDEMYAN SERGEY 10 Apr 2007 21:35
#include<iostream.h>
#include<stdio.h>
int main()
{
int n,i,k;unsigned __int64 a[2000],p;
cin>>n>>k;a[1]=k-1;a[2]=k*(k-1);
for(i=3;i<=n;i++)
{a[i]=(k-1)*(a[i-1]+a[i-2]);p=a[i];}
if(n==1)
cout<<k-1;
else
if(n==2)
cout<<k*(k-1);
else
if(n>=3)
printf("%I64u", p);


return 0;
}
Re: WHY WA#6?HERE IS MY CODE!!THANK!!!!
Posted by Romko [Lviv NU] 10 Apr 2007 22:53
You should use long arithmetic!!!
Re: WHY WA#6?HERE IS MY CODE!!THANK!!!!
Posted by CHIDEMYAN SERGEY 11 Apr 2007 17:17
CAN I SOLVE IT WHITOUT LONG ARITHMETIC?THANK!!!
NO(-)
Posted by Romko [Lviv NU] 11 Apr 2007 18:04
Yes:)
Posted by KIRILL(ArcSTU) 11 Apr 2007 18:08

1)hacking ;) - bad way
2)find answers for all test cases

but more easy to write LA

Edited by author 11.04.2007 18:10
Re: WHY WA#6?HERE IS MY CODE!!THANK!!!!
Posted by Paradox(Petrosian Alexander)~ 11 Apr 2007 18:19
I have the solution!!!
do you want
Re: WHY WA#6?HERE IS MY CODE!!THANK!!!!
Posted by CHIDEMYAN SERGEY 14 Apr 2007 00:26
THANK ALL OF YOU!!!