Đăng nhập để hỏi chi tiết


Hãy luôn nhớ cảm ơn và vote 5*
nếu câu trả lời hữu ích nhé!
#pragma GCC optimize("O2")
#pragma GCC target("avx,avx2,fma")
//----------Huuuu------
#include <bits/stdc++.h>
using namespace std;
//-----------Define---------------
#define __File(name)
/* freopen(name ".inp", "r", stdin);
freopen(name ".out", "w", stdout); */
#define TIME (1.0 * clock() / CLOCKS_PER_SEC)
#define el cout << '\n'
#define ll long long
#define ull unsigned long long
#define big __int128
#define gcd(a, b) abs(__gcd(a, b))
#define lcm(a, b) abs((a) * (b) / gcd(a, b))
#define fix(a, b) fixed << setprecision(a) << (b)
#define all(x) (x).begin(), (x).end()
#define all1(x) (x) + (1), (x) + (n) + (1)
#define rep(i, a, b) for (int i = a; i < b; i++)
#define rep1(i, a, b) for (int i = a; i <= b; i++)
#define out(x)
#define pb push_back
#define pob pop_back()
#define fi first
#define se second
/* __File("t.phistdeptrai");*/
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int s1, v1, s2, v2;
cin >> s1 >> v1 >> s2 >> v2;
if (v1 == v2)
{
if (s1 == s2)
{
cout << 0 << endl;
}
else
{
cout << -1 << endl;
}
}
else
{
int t = int(s2 - s1) / (v1 - v2);
if (t > 0)
{
cout << t << endl;
}
else
{
cout << -1 << endl;
}
}
return 0;
}Hãy giúp mọi người biết câu trả lời này thế nào?
`C++`
#include <iostream>
using namespace std;
int main()
{
// freopen("DRB.INP", "r", stdin);
// freopen("DRB.OUT", "w", stdout);
int S1, V1, S2, V2, t;
cin >> S1 >> V1 >> S2 >> V2;
if (V1 == V2)
cout << -1;
else {
t = (S1 - S2) / (V2 - V1);
if (t >= 0)
cout << t;
else
cout << -1;
}
return 0;
}
Hãy giúp mọi người biết câu trả lời này thế nào?
Bảng tin
0
216
0
Mấy cái define dùng để làm gì vậy ạ?
0
216
0
Sao cậu viết __File("t.phistdeptrai");
0
216
0
Mình test bài của cậu sai Test 7 nhé