hint : use long int to "count" not to "storing Value" & u'll use only 12k
Posted by
ss 21 Aug 2002 14:25
count the 9!!
:-)
Re: hint : use long int to "count" not to "storing Value" & u'll use only 12k
> count the 9!!
> :-)
Tell me more about it !!!! PLEASE !!!!
Re: hint : use long int to "count" not to "storing Value" & u'll use only 12k
Posted by
ss 21 Aug 2002 19:20
more hint :
0 1 -> 1 wait
2 3-> 5 wait print 1
3 4-> 7 wait print 5
0 1 ->1 wait
4 5 -> 9 #1 wait print 1
4 5 ->9 #2 wait
4 5 -> 9 #3 wait
2 2 ->4 <- now- print '9' for 3
0 1 ->1 ->print!
4 5 -> 9 #1 wait
4 5 ->9 #2 wait
4 5 -> 9 #3 wait
5 5 ->10 <- now- print '0' for 3
godd lucK :-)
sorry ,the above is wrong here's the other one
Posted by
ss 21 Aug 2002 19:24
(1)
0 1 -> 1 wait
2 3-> 5 wait print 1
3 4-> 7 wait print 5
.
.
(2)
0 1 ->1 wait
4 5 -> 9 #1 wait
4 5 ->9 #2 wait
4 5 -> 9 #3 wait
2 2 ->4 wait <- now- printf '1' & print '9' for 3
.
.
(3)
0 1 ->1 wait
4 5 -> 9 #1 wait
4 5 ->9 #2 wait
4 5 -> 9 #3 wait
5 5 ->10 wait <- now- printf 1+1=2 & print '0' for 3
.
.
.
good lucK :-)
But I still don't understand !!
> (1)
> 0 1 -> 1 wait
> 2 3-> 5 wait print 1
> 3 4-> 7 wait print 5
> .
> .
> (2)
> 0 1 ->1 wait
> 4 5 -> 9 #1 wait
> 4 5 ->9 #2 wait
> 4 5 -> 9 #3 wait
> 2 2 ->4 wait <- now- printf '1' & print '9' for 3
> .
> .
> (3)
> 0 1 ->1 wait
> 4 5 -> 9 #1 wait
> 4 5 ->9 #2 wait
> 4 5 -> 9 #3 wait
> 5 5 ->10 wait <- now- printf 1+1=2 & print '0' for 3
> .
> .
> .
> good lucK :-)
>
>
it means:
Posted by
ss 22 Aug 2002 19:48
u can print the sum of the number you're reading now when you've found
the sum after them !=9 if the sum after them ==9 just count it ......
1.when you've read the sum<9 print all the number BEFORE them then
start reading again and the last sum you've made become the firt one
2.when ugot sum>9 print the first one+! and all the nine-->0 the now the
first one is the last sum%10 got it? the main idea is u can stored the
number in the way x 9 9 9 9 ..... but just remember the first one ans
COUNT the nine..........
sorry for my eng...
Re: it means:
Thank you !!!
If you want to make a friend, mail me: Devil_hunter@mail.ru
but...
Posted by
let 12 Apr 2004 18:48
but it may not work if the sum of every line is 9....
4 5 -> 9 wait
4 5 -> 9 #1wait
4 5 -> 9 #2wait
4 5 -> 9 #3wait
. . . . .
. . . . .
. . . . .
4 5-> 9 #999999wait
1 3-> than printf
if input just like this,how to solve it??
Re: but...
Posted by
sloboz 13 Apr 2004 05:26
you count the nines and the zeroes. If current sum is larger than 10 you print the zeroes from the "buffer" otherwise you print the nines.
If you want a source code... nah, better not.
Data size: only 20 bytes.
Re: it means:
i did it according to your methods but still got WA even in the very first test1...ft...
but every test datas i could see are all made to be used into my local IDE and turned out to be correct...
why? i really dunno...ft...again...
any help would be appreciated as deeply as possible...
Re: it means:
//here's my prog...
#include <iostream>
#include <vector>
using namespace std;
int main()
{
long i,former,latter,n,c,count9=0;
vector<long> a(0);
cin>>n;
for(i=0;i<2*n;i++)
{
cin>>c;
a.push_back(c);
}
former=a[0]+a[1];
for(i=0;i<2*n;i+=2)
{
latter=a[i+2]+a[i+3];
if(n>=2)
{
if(latter<10)
{
if(latter==9)
{
count9++;
if(i+3==2*n-1)
{
cout<<former;
while(count9--)
cout<<9;
}
}
else if(latter!=9&&count9==0)
{
cout<<former;
former=latter;
}
else if(latter!=9&&count9>0)
{
cout<<former;
while(count9--)
cout<<9;
cout<<latter;
}
}
else
{
if(count9)
{
cout<<former+1;
while(count9--)
cout<<0;
cout<<latter%10;
}
else
{
cout<<former+1;
former=latter%10;
}
}
}
else
cout<<former<<endl;
}
return 0;
}