Page 3 of 4
10346 WA
Posted: Mon Jan 23, 2006 6:08 pm
by athlon19831
please help me
#include "iostream.h"
int main(int argc, char* argv[])
{
long n,k;
long sum;
while(cin>>n>>k)
{
sum=n;
if(k>1)
{
while(n>=k)
{
sum+=n/k;
n=n/k;
}
cout<<sum<<endl;
}
}
return 0;
}
Posted: Sun Feb 05, 2006 9:11 am
by Wei-Ming Chen
If the input is
31 2
The output might be 61
But your output says 57
Becare of the problem:
31/2=15...1
15/2=7....1
7/2=3....1
3/2=1....1
so your output is 31+15+7+1=57
But there are five 1 left!!
10346
Posted: Sun Aug 20, 2006 8:09 am
by ishtiaq ahmed
Actully i dont know why i am facing wrong ans
plz help me.i am a beginner in programmig
my code is
Code: Select all
#include<stdio.h>
void main()
{
long long a,b,sum;
while(scanf("%lld %lld",&a,&b)!=EOF)
{
if(b>1)
{
sum=a;
while(a!=0)
{
a=a/b;
sum= sum+a;
}
printf("%lld\n",sum);
}
}
}
Posted: Sun Aug 20, 2006 8:52 am
by DP
You can check this I/O:
Output:
1 1 1 =3
---
1 =1
1
----- =1
Total =5
Posted: Wed Feb 07, 2007 3:26 pm
by newton
delete your code and check the link. you will get more information about peter problem.
http://online-judge.uva.es/board/viewto ... ight=10346
newton... simply the best
10346 WA
Posted: Fri Apr 13, 2007 7:02 pm
by KaDeG
I have made the 10346 problem but got Wa. I searched the forums and found the smart formula: sumciggaret=n+(n-1)/(k-1); I did this and got AC. The problem is with my code, the first idea i had i got WA, the problem testcases works fine and also some other testecase i created from my AC program are OK.
But i still get WA, any ideas why would be helpful...
Code: Select all
#include <stdio.h>
main() {
int n, k, sum, nk;
while((scanf("%d %d", &n, &k))==2) {
sum=n;
nk=sum/k;
sum+=nk;
while(nk>=k) {
nk/=k;
sum+=nk;
}
printf("%d\n", sum);
}
}
Thanks
Posted: Fri Apr 13, 2007 8:49 pm
by Jan
Try the cases...
Input:
Output:
Hope these help.
Posted: Fri Apr 13, 2007 10:45 pm
by KaDeG
yeah, fixed and got AC
thanks

Re: 10346 - Peter’s Smokes
Posted: Fri Jun 05, 2009 1:49 pm
by asif_khan_ak_07
I wrote the following code and got WA.I tried some test cases and the answers were correct.pls help me to find the mistake
Code: Select all
#include<stdio.h>
int main()
{
long double x,n,ans,r;
while((scanf("%Lf %Lf",&x,&n)==2))
{
if(x<n)
printf("%.0Lf\n",x);
else
{
ans=x;
r=x/n;
do
{
ans=ans+r;
r=r/n;
}while(r>=1);
printf("%.0Lf\n",ans);
}
}
return 0;
}
Re: 10346 - Peter’s Smokes
Posted: Fri Jun 05, 2009 9:40 pm
by saiful_sust
Hi asif_khan
Try this case:
INPUT:
Code: Select all
12 3
1200 5
1200 1200
3 2
25326 3652
456987 326596
OUTPUT:
[*] IMPOSSIBLE MEANS I M POSSIBLE /[*]
Re: 10346 - Peter’s Smokes
Posted: Mon Nov 09, 2009 4:19 pm
by kaysar_buet08
where is my error!!
#include<stdio.h>
int n,a,b;
int main()
{
while((scanf("%d%d",&a,&b))!=EOF)
{
n=a;
while(a>=b)
{
a=a/b;
n+=a;
}
printf("%d\n",n);
}
return 0;
}
Re: 10346 - Peter’s Smokes
Posted: Thu Feb 25, 2010 8:04 am
by khairul
hi kaysar u must keep rest by modules operator.
suppose,
5 3
output should 7 not 6.
because 5+1+1=5+1+((1+2))/3=7
and also use unsigned int/long.
i think it would work and let me know...
thanks,
khairul
10346- Peter's Smokes
Posted: Sat Sep 20, 2014 1:03 pm
by imran_12
I cant understand why i am getting WA..
plz help
Code: Select all
#include<stdio.h>
int main()
{
int n,k,m,p;
while(scanf("%d %d",&n,&k)==2)
{
m=n;
if(k>1)
{
p=n%k;
n=n/k;
p=(p+n)/k;
m=m+n+p;
}
printf("%d\n",m);
}
}
Re: 10346- Peter's Smokes
Posted: Sat Sep 20, 2014 1:23 pm
by lighted
Use search and post in existing thread.
http://acm.uva.es/board/search.php?keyw ... f03df06864
Input
Acc Output
Your Output
You are doing rolling process one time using if operator. I do it as many as it is possible using loop.
Re: 10346 - Peter's Smokes
Posted: Wed Oct 29, 2014 8:14 pm
by tomb_raider
Why Wrong ANSWER MANNNNN !?!?!?!?!?!?
Code: Select all
#include <stdio.h>
int main()
{
long long int a,b,x,y,c,sum1,sum2;
while(scanf("%lld %lld",&a,&b)==2)
{
sum1=0,sum2=0,c=0;
while(a>0)
{
x=a%b;
sum2=x+sum2;
if(sum2/b>0)
{
c++;
sum2=sum2/b;
}
sum1=sum1+a;
a=a/b;
}
sum1=sum1+c;
printf("%lld\n",sum1);
}
return 0;
}