結果
問題 | No.383 レーティング |
ユーザー |
|
提出日時 | 2018-05-03 18:36:30 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 814 bytes |
コンパイル時間 | 642 ms |
コンパイル使用メモリ | 67,232 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-28 00:47:38 |
合計ジャッジ時間 | 1,300 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 14 |
ソースコード
#include <iostream>#include <string>using namespace std;string trim(string);int main() {char getline[100];string s;cin.getline( getline , sizeof(getline));s = getline;s = trim(s);int a = s.find(" ");string s1 = s.substr(0, a);s1 = trim(s1);string s2 = s.substr(a, s.size());s2 = trim(s2);int num1 = stoi(s1);int num2 = stoi(s2);int result = num2 - num1;if (result > 0) {cout << "+" << result << endl;}else if (result == 0) {cout << result << endl;}else {cout << result << endl;}return 0;}string trim(string s) {while (true) {if (s.substr(0, 1) == " ") {s = s.substr(1, s.size() - 1);}else {break;}}while (true) {if (s.substr(s.size() - 1, 1) == " ") {s = s.substr(0, s.size() - 1);}else {break;}}return s;}