#include <bits/stdc++.h>
using namespace std;
int main(){
long long t;
cin>>t;
for(int j=0;j<t;j++){
long long n,s,y;
cin>>n>>s;
y=s/((n/2)+1);
cout<<y<<endl;
}
return 0;
}
using namespace std;
int main(){
long long t;
cin>>t;
for(int j=0;j<t;j++){
long long n,s,y;
cin>>n>>s;
y=s/((n/2)+1);
cout<<y<<endl;
}
return 0;
}
Competitive Programming Solutions
Capture.PNG
OTHER SOLUTION
#include <bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin >> t;
while (t--)
{
int n;
cin>>n;
if(n%4==0)cout<<"North"<<endl;
else if(n%4==2)cout<<"South"<<endl;
else if(n%4==3)cout<<"West"<<endl;
else cout<<"East"<<endl;
}
return 0;
}
#include <bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin >> t;
while (t--)
{
int n;
cin>>n;
if(n%4==0)cout<<"North"<<endl;
else if(n%4==2)cout<<"South"<<endl;
else if(n%4==3)cout<<"West"<<endl;
else cout<<"East"<<endl;
}
return 0;
}
#include <bits/stdc++.h>
using namespace std;
int main() {
// your code goes here
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
if(n&1)
{vector<vector<int>>v(n,vector<int>(n,1));
int k=0;
for(int i=0;i<n;i++)
{
v[i][k]=-1;
k++;
}
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
cout<<v[i][j]<<" ";
cout<<endl;
}
}
else
{
vector<vector<int>>v(n,vector<int>(n,-1));
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
cout<<v[i][j]<<" ";
cout<<endl;
}
}
}
return 0;
}COUNTDOWN SOLUTION CODEFORCES
#include <bits/stdc++.h>
using namespace std;
#define ff(a, c) for (int(a) = 0; (a) < (c); (a)++)
#define int long long int
int32_t main() {
w(t) {
int n;
cin >> n;
string s;
cin >> s;
int ans = 0;
ff(i, n) {
if (s[i] != '0') {
ans += int32_t(s[i] - int32_t('0'));
if (i != n - 1) ans++;
}
}
cout << ans << endl;
}
return 0;
}
#include <bits/stdc++.h>
using namespace std;
#define ff(a, c) for (int(a) = 0; (a) < (c); (a)++)
#define int long long int
int32_t main() {
w(t) {
int n;
cin >> n;
string s;
cin >> s;
int ans = 0;
ff(i, n) {
if (s[i] != '0') {
ans += int32_t(s[i] - int32_t('0'));
if (i != n - 1) ans++;
}
}
cout << ans << endl;
}
return 0;
}
#include <bits/stdc++.h>
using namespace std;
#define ll long long
void solve();
int main()
{
//@cpsolutions
ios_base::sync_with_stdio(false);
cin.tie(NULL);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("error.txt", "w", stderr);
freopen("output.txt", "w", stdout);
#endif
ll int t=1;
/*is Single Test case?*/
cin >> t;
// t=1;
//single test case -= Delete if t testCases =-
while (t--) {
solve();
cout << "\n";
}
cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl;
int z;
cin>>z;
return 0;
}
void solve()
{
ll n;cin>>n;
if(n%4 == 0) cout<<"NO";
else cout<<"YES";
}
using namespace std;
#define ll long long
void solve();
int main()
{
//@cpsolutions
ios_base::sync_with_stdio(false);
cin.tie(NULL);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("error.txt", "w", stderr);
freopen("output.txt", "w", stdout);
#endif
ll int t=1;
/*is Single Test case?*/
cin >> t;
// t=1;
//single test case -= Delete if t testCases =-
while (t--) {
solve();
cout << "\n";
}
cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl;
int z;
cin>>z;
return 0;
}
void solve()
{
ll n;cin>>n;
if(n%4 == 0) cout<<"NO";
else cout<<"YES";
}
#include <iostream>
using namespace std;
int main() {
int t;
cin >> t;
while(t--)
{
int i, num;
cin >> num;
for(i = 1; i <= num; i++) {
cout << i << " ";
}
cout<<"\n";
}
return 0;
}
using namespace std;
int main() {
int t;
cin >> t;
while(t--)
{
int i, num;
cin >> num;
for(i = 1; i <= num; i++) {
cout << i << " ";
}
cout<<"\n";
}
return 0;
}