鹽水的故事
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 19615 Accepted Submission(s): 4977
結果 | 時間 | 內存 | 代碼長度 | 語言 |
Accepted | 0MS | 1516K | 743B | G++ |
#include<stdio.h>
int main()
{
double VUL,D;
int n,t;
while(scanf("%lf%lf",&VUL,&D)!=EOF)//這是編程運行時輸入數據的終止條件,當輸入的不是兩個數值時,不執行下面代碼;
{
n=1;
t=0;
int f=1;
while(VUL)
{
if(VUL/D>=n)
{
VUL-=n*D;
t+=n++;
t++;
}
else
{
double x=VUL/D;
if(x-(int)x>0.00000001)//精度判斷;
(int)x++;
t+=x;
VUL=0;
f=0;
}
}
if(f)
t--;//正好滴完,則最後不需要等待一秒,所以t應該減1;
printf("%d\n",t);
}
return 0;
}