Submission #00071


ソースコード

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
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
using namespace std;
int main() {
int s, t, d;
cin >> s >> t >> d;
if (s < t) {
for (int i = 1; 1; i++) {
s += d;
if (s > t) {
cout << -1 << "\n";
break;
} else if (s == t) {
cout << i << "\n";
break;
}
}
} else {
for (int i = 1; 1; i++) {
s -= d;
if (s < t) {
cout << -1 << "\n";
break;
} else if (s == t) {
cout << i << "\n";
break;
}
}
}
return(0);
}

ステータス

項目 データ
問題 0009 - ぴょん
ユーザー名 woody_1227
投稿日時 2022-07-19 17:02:29
言語 C++17
状態 Accepted
得点 1
ソースコード長 699 Byte
最大実行時間 29 ms
最大メモリ使用量 648 KB

セット

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

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
01_sample1.txt AC 17 ms 476 KB
1
01_sample2.txt AC 21 ms 576 KB
1
01_sample3.txt AC 19 ms 548 KB
1
02_handmake1.txt AC 23 ms 648 KB
1
02_handmake2.txt AC 20 ms 620 KB
1
02_handmake3.txt AC 29 ms 592 KB
1
02_handmake4.txt AC 18 ms 560 KB
1
02_handmake5.txt AC 18 ms 528 KB
1
02_handmake6.txt AC 21 ms 628 KB
1