本站遷移

因為我最近租用了網路空間以及網域,
故本站已遷移至新網站~
這邊的資訊已經正在進行搬移的工作~
希望各位可以到新網站去逛XD

New Website:
http://knightzone.org/

搜尋此網誌

2011年3月15日 星期二

[UVa]11689:Soda Surpler

這題要注意的是:換完後的汽水罐,等喝完後還可以再換,所以不是只能換一次這樣。

[C](0.012)
#include<stdio.h>
int main()
{
int N;
while( scanf( "%d", &N ) != EOF )
{
int e, f, c;
int i;
for( i = 0 ; i < N ; i++ )
{
int soda = 0;
scanf( "%d%d%d", &e, &f, &c );
int temp = (e+f)/c, other = (e+f)%c, tmp;
while( temp )
{
soda += temp;
tmp = (temp+other)%c;
temp = (temp+other)/c;
other = tmp;
}
printf( "%d\n", soda );
}
}
return 0;
}
view raw UVa11689.c hosted with ❤ by GitHub

0 意見:

張貼留言