File tree Expand file tree Collapse file tree 7 files changed +53
-22
lines changed
Expand file tree Collapse file tree 7 files changed +53
-22
lines changed Original file line number Diff line number Diff line change @@ -29,13 +29,35 @@ int main()
2929 cin >> tc;
3030 while (tc--)
3131 {
32- double r, b, d;
33- cin >> r >> b >> d;
34- double less = (r > b) ? b : r;
35- double big = (r > b) ? r : b;
36- if (ceil ((big - less) / less) > d)
32+ ll n, x;
33+ cin >> n >> x;
34+ ll arr[n];
35+ ll sum = 0 ;
36+ for (ll i = 0 ; i < n; i++)
37+ {
38+ cin >> arr[i];
39+ sum += arr[i];
40+ }
41+ if (sum == x)
3742 cout << " NO" << endl;
3843 else
44+ {
3945 cout << " YES" << endl;
46+ ll currsum = 0 ;
47+ for (ll i = 0 ; i < n; i++)
48+ {
49+ currsum += arr[i];
50+ if (currsum == x)
51+ {
52+ cout << arr[i + 1 ] << " " << arr[i] << " " ;
53+ i++;
54+ }
55+ else
56+ {
57+ cout << arr[i] << " " ;
58+ }
59+ }
60+ cout << endl;
61+ }
4062 }
4163}
Original file line number Diff line number Diff line change @@ -17,6 +17,15 @@ GitHub: https://github.com/Hard-Coder05
1717 cout.tie(NULL );
1818using namespace std ;
1919typedef long long ll;
20+ bool isPerfectSquare (long double x)
21+ {
22+ if (x >= 0 )
23+ {
24+ long long sr = sqrt (x);
25+ return (sr * sr == x);
26+ }
27+ return false ;
28+ }
2029int main ()
2130{
2231 FIO;
@@ -28,9 +37,9 @@ int main()
2837 cin >> tc;
2938 while (tc--)
3039 {
31- ll n, m, k ;
32- cin >> n >> m >> k ;
33- if (((n - 1 ) + n * (m - 1 )) == k )
40+ long double n ;
41+ cin >> n;
42+ if (isPerfectSquare (n / 2 ) || isPerfectSquare (n / 4 ) )
3443 cout << " YES" << endl;
3544 else
3645 cout << " NO" << endl;
Original file line number Diff line number Diff line change @@ -7,22 +7,26 @@ GitHub: https://github.com/Hard-Coder05
77*/
88#include < bits/stdc++.h>
99#define endl " \n "
10- #define max (a, b ) (a < b ? b : a)
11- #define min (a, b ) ((a > b) ? b : a)
10+ #define max (a, b ) (a < b ? b : a)
11+ #define min (a, b ) ((a > b) ? b : a)
1212#define MOD 1000000007
1313#define INF 1000000000000000003
14- #define FIO ios_base::sync_with_stdio (false );cin.tie(NULL );cout.tie(NULL );
14+ #define FIO \
15+ ios_base::sync_with_stdio (false ); \
16+ cin.tie(NULL ); \
17+ cout.tie(NULL );
1518using namespace std ;
1619typedef long long ll;
17- int main () {
20+ int main ()
21+ {
1822 FIO;
1923#ifndef ONLINE_JUDGE
2024 freopen (" input.txt" , " r" , stdin);
2125 freopen (" output.txt" , " w" , stdout);
2226#endif
2327 ll tc;
2428 cin >> tc;
25- while (tc--) {
26-
29+ while (tc--)
30+ {
2731 }
2832}
Original file line number Diff line number Diff line change 1+ 4
2+ 2
3+ 4
146
2- 1 1 0
3- 2 2 2
4- 2 2 3
5- 2 2 4
6- 1 4 3
7- 100 100 10000
5+ 1
Original file line number Diff line number Diff line change 11YES
2- NO
32YES
43NO
5- YES
64NO
You can’t perform that action at this time.
0 commit comments