10346 - Peter's Smokes
Moderator: Board moderators
-
- New poster
- Posts: 20
- Joined: Thu Jan 19, 2006 2:32 pm
10346 WA
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;
}
#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;
}
-
- Experienced poster
- Posts: 122
- Joined: Sun Nov 13, 2005 10:25 am
- Location: Taiwan
-
- Learning poster
- Posts: 53
- Joined: Sat Jul 29, 2006 7:33 am
- Location: (CSE,DU), Dhaka,Bangladesh
10346
Actully i dont know why i am facing wrong ans
plz help me.i am a beginner in programmig
my code is
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);
}
}
}
Last edited by ishtiaq ahmed on Wed Feb 07, 2007 1:50 pm, edited 2 times in total.
You can check this I/O:
Output:
1 1 1 =3
---
1 =1
1
----- =1
Total =5
Code: Select all
3 2
Code: Select all
5
---
1 =1
1
----- =1
Total =5
-
- Experienced poster
- Posts: 162
- Joined: Thu Jul 13, 2006 7:07 am
- Location: Campus Area. Dhaka.Bangladesh
- Contact:
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
http://online-judge.uva.es/board/viewto ... ight=10346
newton... simply the best
10346 WA
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...
Thanks
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);
}
}
/*No Comment*/
Try the cases...
Input:
Output:
Hope these help.
Input:
Code: Select all
8492 142
15881 300
10677 119
Code: Select all
8552
15934
10767
Ami ekhono shopno dekhi...
HomePage
HomePage
-
- New poster
- Posts: 25
- Joined: Fri Apr 17, 2009 8:24 am
Re: 10346 - Peter’s Smokes
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;
}
-
- Learning poster
- Posts: 97
- Joined: Fri Aug 22, 2008 10:18 pm
- Location: CSE.SUST.SYLHET
Re: 10346 - Peter’s Smokes
Hi asif_khan
Try this case:
INPUT:
Code: Select all
12 3
1200 5
1200 1200
3 2
25326 3652
456987 326596
OUTPUT:
Code: Select all
17
1499
1201
5
25332
456988
-
- New poster
- Posts: 1
- Joined: Mon Nov 09, 2009 4:00 pm
Re: 10346 - Peter’s Smokes
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;
}

#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
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
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
I cant understand why i am getting WA..
plz help
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
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.
Input
Code: Select all
1000 5
Code: Select all
1249
Code: Select all
1240
A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman
-
- New poster
- Posts: 2
- Joined: Tue Oct 28, 2014 8:42 am
Re: 10346 - Peter's Smokes
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;
}
Last edited by brianfry713 on Wed Oct 29, 2014 9:11 pm, edited 1 time in total.
Reason: Added code blocks
Reason: Added code blocks