Submission #45099


ソースコード

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include<iostream>
#include<math.h>
using namespace std;
int main() {
//while(1){//確認用
int A, B;
long long T, day = 0, money = 0;
long long str, end;
cin >> A >> B >> T;
str = 1;
end = T;
while (str < end) {
day = (end + str) / 2;
//cout << day << "日目の貯金は";
long long a = sqrt(day);
long long b = day - a;
money = a * A + b * B;
//cout << money << "円" << endl;
if (money < T) {
str = day + 1;
//cout << "moneyがTより小さいのでstrを" << str << "に変更" << endl;
}
else {
end = day - 1;
//cout << "moneyがTより大きいのでendを" << end << "に変更" << endl;
}
}
long long nowa = sqrt(str), nowb = str - nowa;
long long now = nowa*A + nowb*B;
//long long yes = sqrt(str - 1)*A + ((str - 1) - sqrt(str - 1))*B;
//cout << str << "日の" << now << "円が境界線" << endl; //<< "前日は" << yes << "円" << endl;
if (now<T) {
str++;
}
cout << str << endl;
//}
}

ステータス

項目 データ
問題 0993 - 貯金 (Saving Money)
ユーザー名 sairen
投稿日時 2018-11-17 10:23:18
言語 C++11
状態 Accepted
得点 10
ソースコード長 1009 Byte
最大実行時間 39 ms
最大メモリ使用量 724 KB

セット

セット 得点 Cases
1 ALL 10 / 10 *

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
input-sample01 AC 30 ms 604 KB
1
input-sample02 AC 23 ms 704 KB
1
input-sample03 AC 26 ms 552 KB
1
input01 AC 24 ms 656 KB
1
input02 AC 21 ms 500 KB
1
input03 AC 19 ms 472 KB
1
input04 AC 21 ms 444 KB
1
input05 AC 20 ms 540 KB
1
input06 AC 25 ms 516 KB
1
input07 AC 22 ms 488 KB
1
input08 AC 21 ms 584 KB
1
input09 AC 22 ms 432 KB
1
input10 AC 24 ms 532 KB
1
input11 AC 39 ms 500 KB
1
input12 AC 21 ms 600 KB
1
input13 AC 20 ms 704 KB
1
input14 AC 22 ms 676 KB
1
input15 AC 17 ms 516 KB
1
input16 AC 23 ms 488 KB
1
input17 AC 17 ms 464 KB
1
input18 AC 26 ms 564 KB
1
input19 AC 26 ms 664 KB
1
input20 AC 17 ms 636 KB
1
input21 AC 24 ms 604 KB
1
input22 AC 27 ms 576 KB
1
input23 AC 20 ms 548 KB
1
input24 AC 26 ms 648 KB
1
input25 AC 26 ms 616 KB
1
input26 AC 30 ms 460 KB
1
input27 AC 17 ms 564 KB
1
input28 AC 23 ms 656 KB
1
input29 AC 19 ms 624 KB
1
input30 AC 23 ms 724 KB
1