moved to codes folder
This commit is contained in:
parent
00ae13589c
commit
91873af905
@ -1,86 +1,86 @@
|
|||||||
#include<bits/stdc++.h>
|
#include<bits/stdc++.h>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
#define ll long long
|
#define ll long long
|
||||||
#define ul unsigned long long
|
#define ul unsigned long long
|
||||||
#define pb push_back
|
#define pb push_back
|
||||||
#define ss second
|
#define ss second
|
||||||
#define ff first
|
#define ff first
|
||||||
#define fr(n) for(int i=0; i<n; i++)
|
#define fr(n) for(int i=0; i<n; i++)
|
||||||
#define fro(n) for(int i=1; i<n; i++)
|
#define fro(n) for(int i=1; i<n; i++)
|
||||||
#define frj(n) for(int j=0; j<n; j++)
|
#define frj(n) for(int j=0; j<n; j++)
|
||||||
#define frr(n) for(int i=n; i>=0; i--)
|
#define frr(n) for(int i=n; i>=0; i--)
|
||||||
#define nl '\n'
|
#define nl '\n'
|
||||||
#define yes cout<<"YES"<<nl
|
#define yes cout<<"YES"<<nl
|
||||||
#define no cout<<"NO"<<nl
|
#define no cout<<"NO"<<nl
|
||||||
#define all(x) x.begin(), x.end()
|
#define all(x) x.begin(), x.end()
|
||||||
#define dbg(x) cerr << #x <<" "<< x << endl;
|
#define dbg(x) cerr << #x <<" "<< x << endl;
|
||||||
#define fast_io (ios_base:: sync_with_stdio(false),cin.tie(NULL));
|
#define fast_io (ios_base:: sync_with_stdio(false),cin.tie(NULL));
|
||||||
|
|
||||||
#define PI 3.141592653589793238
|
#define PI 3.141592653589793238
|
||||||
#define INF LONG_LONG_MAX
|
#define INF LONG_LONG_MAX
|
||||||
#define MOD 1e9+7
|
#define MOD 1e9+7
|
||||||
|
|
||||||
ll fact(ll n){ if(n==0) return 1; ll res = 1; for (ll i = 2; i <= n; i++) res = res * i; return res;}
|
ll fact(ll n){ if(n==0) return 1; ll res = 1; for (ll i = 2; i <= n; i++) res = res * i; return res;}
|
||||||
ll nPr(ll n, ll r) { return fact(n) / fact(n - r); }
|
ll nPr(ll n, ll r) { return fact(n) / fact(n - r); }
|
||||||
ll nCr(ll n, ll r) { return fact(n) / (fact(r) * fact(n - r)); }
|
ll nCr(ll n, ll r) { return fact(n) / (fact(r) * fact(n - r)); }
|
||||||
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
|
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
|
||||||
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b);}
|
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b);}
|
||||||
ll mypow(ll a, ll b){ ll ans = 1; while(b){ if (b&1) ans = (ans*a) ; b /= 2; a = (a*a); } return ans; }
|
ll mypow(ll a, ll b){ ll ans = 1; while(b){ if (b&1) ans = (ans*a) ; b /= 2; a = (a*a); } return ans; }
|
||||||
bool isPrime(ll n) { if(n <= 1) return false; for(ll i = 2; i <= sqrt(n); i++) if(n % i == 0) return false; return true;}
|
bool isPrime(ll n) { if(n <= 1) return false; for(ll i = 2; i <= sqrt(n); i++) if(n % i == 0) return false; return true;}
|
||||||
|
|
||||||
//////////////////////////////////Code Start/////////////////////////////////////
|
//////////////////////////////////Code Start/////////////////////////////////////
|
||||||
|
|
||||||
void solve()
|
void solve()
|
||||||
{
|
{
|
||||||
int n;
|
int n;
|
||||||
cin>>n;
|
cin>>n;
|
||||||
n++;
|
n++;
|
||||||
for(int i=1; i<=n; ++i)
|
for(int i=1; i<=n; ++i)
|
||||||
{
|
{
|
||||||
int p=0;
|
int p=0;
|
||||||
for(int j=i; j<n; ++j)
|
for(int j=i; j<n; ++j)
|
||||||
cout<<" ";
|
cout<<" ";
|
||||||
for(int j=0; j<i-1; ++j)
|
for(int j=0; j<i-1; ++j)
|
||||||
{
|
{
|
||||||
cout<<p++;
|
cout<<p++;
|
||||||
if(j+1<i)
|
if(j+1<i)
|
||||||
cout<<" ";
|
cout<<" ";
|
||||||
}
|
}
|
||||||
for(int j=0; j<i; ++j)
|
for(int j=0; j<i; ++j)
|
||||||
{
|
{
|
||||||
cout<<p--;
|
cout<<p--;
|
||||||
if(j+1<i)
|
if(j+1<i)
|
||||||
cout<<" ";
|
cout<<" ";
|
||||||
}
|
}
|
||||||
cout<<endl;
|
cout<<endl;
|
||||||
}
|
}
|
||||||
n--;
|
n--;
|
||||||
for(int i=0; i<=n; ++i)
|
for(int i=0; i<=n; ++i)
|
||||||
{
|
{
|
||||||
int p=0;
|
int p=0;
|
||||||
for(int j=0; j<=i; ++j)
|
for(int j=0; j<=i; ++j)
|
||||||
cout<<" ";
|
cout<<" ";
|
||||||
for(int j=i; j<n-1; ++j)
|
for(int j=i; j<n-1; ++j)
|
||||||
{
|
{
|
||||||
cout<<p++;
|
cout<<p++;
|
||||||
if(j+1<n)
|
if(j+1<n)
|
||||||
cout<<" ";
|
cout<<" ";
|
||||||
}
|
}
|
||||||
for(int j=i; j<n; ++j)
|
for(int j=i; j<n; ++j)
|
||||||
{
|
{
|
||||||
cout<<p--;
|
cout<<p--;
|
||||||
if(j+1<n)
|
if(j+1<n)
|
||||||
cout<<" ";
|
cout<<" ";
|
||||||
}
|
}
|
||||||
cout<<endl;
|
cout<<endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
fast_io;
|
fast_io;
|
||||||
int TC = 1;
|
int TC = 1;
|
||||||
//cin >> TC;
|
//cin >> TC;
|
||||||
while (TC--) solve();
|
while (TC--) solve();
|
||||||
}
|
}
|
@ -1,49 +1,49 @@
|
|||||||
#include<bits/stdc++.h>
|
#include<bits/stdc++.h>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
#define ll long long
|
#define ll long long
|
||||||
#define ul unsigned long long
|
#define ul unsigned long long
|
||||||
#define pb push_back
|
#define pb push_back
|
||||||
#define ss second
|
#define ss second
|
||||||
#define ff first
|
#define ff first
|
||||||
#define fr(n) for(int i=0; i<n; i++)
|
#define fr(n) for(int i=0; i<n; i++)
|
||||||
#define fro(n) for(int i=1; i<n; i++)
|
#define fro(n) for(int i=1; i<n; i++)
|
||||||
#define frj(n) for(int j=0; j<n; j++)
|
#define frj(n) for(int j=0; j<n; j++)
|
||||||
#define frr(n) for(int i=n; i>=0; i--)
|
#define frr(n) for(int i=n; i>=0; i--)
|
||||||
#define nl '\n'
|
#define nl '\n'
|
||||||
#define yes cout<<"YES"<<nl
|
#define yes cout<<"YES"<<nl
|
||||||
#define no cout<<"NO"<<nl
|
#define no cout<<"NO"<<nl
|
||||||
#define all(x) x.begin(), x.end()
|
#define all(x) x.begin(), x.end()
|
||||||
#define dbg(x) cerr << #x <<" "<< x << endl;
|
#define dbg(x) cerr << #x <<" "<< x << endl;
|
||||||
#define fast_io (ios_base:: sync_with_stdio(false),cin.tie(NULL));
|
#define fast_io (ios_base:: sync_with_stdio(false),cin.tie(NULL));
|
||||||
|
|
||||||
#define PI 3.141592653589793238
|
#define PI 3.141592653589793238
|
||||||
#define INF LONG_LONG_MAX
|
#define INF LONG_LONG_MAX
|
||||||
#define MOD 1e9+7
|
#define MOD 1e9+7
|
||||||
|
|
||||||
ll fact(ll n){ if(n==0) return 1; ll res = 1; for (ll i = 2; i <= n; i++) res = res * i; return res;}
|
ll fact(ll n){ if(n==0) return 1; ll res = 1; for (ll i = 2; i <= n; i++) res = res * i; return res;}
|
||||||
ll nPr(ll n, ll r) { return fact(n) / fact(n - r); }
|
ll nPr(ll n, ll r) { return fact(n) / fact(n - r); }
|
||||||
ll nCr(ll n, ll r) { return fact(n) / (fact(r) * fact(n - r)); }
|
ll nCr(ll n, ll r) { return fact(n) / (fact(r) * fact(n - r)); }
|
||||||
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
|
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
|
||||||
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b);}
|
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b);}
|
||||||
ll mypow(ll a, ll b){ ll ans = 1; while(b){ if (b&1) ans = (ans*a) ; b /= 2; a = (a*a); } return ans; }
|
ll mypow(ll a, ll b){ ll ans = 1; while(b){ if (b&1) ans = (ans*a) ; b /= 2; a = (a*a); } return ans; }
|
||||||
bool isPrime(ll n) { if(n <= 1) return false; for(ll i = 2; i <= sqrt(n); i++) if(n % i == 0) return false; return true;}
|
bool isPrime(ll n) { if(n <= 1) return false; for(ll i = 2; i <= sqrt(n); i++) if(n % i == 0) return false; return true;}
|
||||||
|
|
||||||
//////////////////////////////////Code Start/////////////////////////////////////
|
//////////////////////////////////Code Start/////////////////////////////////////
|
||||||
|
|
||||||
void solve()
|
void solve()
|
||||||
{
|
{
|
||||||
int x,y;
|
int x,y;
|
||||||
cin>>x>>y;
|
cin>>x>>y;
|
||||||
if(x%y)
|
if(x%y)
|
||||||
cout<<y-(x%y)<<nl;
|
cout<<y-(x%y)<<nl;
|
||||||
else
|
else
|
||||||
cout<<0<<nl;
|
cout<<0<<nl;
|
||||||
}
|
}
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
fast_io;
|
fast_io;
|
||||||
int TC = 1;
|
int TC = 1;
|
||||||
cin >> TC;
|
cin >> TC;
|
||||||
while (TC--) solve();
|
while (TC--) solve();
|
||||||
}
|
}
|
@ -1,56 +1,56 @@
|
|||||||
#include<bits/stdc++.h>
|
#include<bits/stdc++.h>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
#define ll long long
|
#define ll long long
|
||||||
#define ul unsigned long long
|
#define ul unsigned long long
|
||||||
#define pb push_back
|
#define pb push_back
|
||||||
#define ss second
|
#define ss second
|
||||||
#define ff first
|
#define ff first
|
||||||
#define fr(n) for(int i=0; i<n; i++)
|
#define fr(n) for(int i=0; i<n; i++)
|
||||||
#define fro(n) for(int i=1; i<n; i++)
|
#define fro(n) for(int i=1; i<n; i++)
|
||||||
#define frj(n) for(int j=0; j<n; j++)
|
#define frj(n) for(int j=0; j<n; j++)
|
||||||
#define frr(n) for(int i=n; i>=0; i--)
|
#define frr(n) for(int i=n; i>=0; i--)
|
||||||
#define nl '\n'
|
#define nl '\n'
|
||||||
#define yes cout<<"YES"<<nl
|
#define yes cout<<"YES"<<nl
|
||||||
#define no cout<<"NO"<<nl
|
#define no cout<<"NO"<<nl
|
||||||
#define all(x) x.begin(), x.end()
|
#define all(x) x.begin(), x.end()
|
||||||
#define dbg(x) cerr << #x <<" "<< x << endl;
|
#define dbg(x) cerr << #x <<" "<< x << endl;
|
||||||
#define fast_io (ios_base:: sync_with_stdio(false),cin.tie(NULL));
|
#define fast_io (ios_base:: sync_with_stdio(false),cin.tie(NULL));
|
||||||
|
|
||||||
#define PI 3.141592653589793238
|
#define PI 3.141592653589793238
|
||||||
#define INF LONG_LONG_MAX
|
#define INF LONG_LONG_MAX
|
||||||
#define MOD 1e9+7
|
#define MOD 1e9+7
|
||||||
|
|
||||||
ll fact(ll n){ if(n==0) return 1; ll res = 1; for (ll i = 2; i <= n; i++) res = res * i; return res;}
|
ll fact(ll n){ if(n==0) return 1; ll res = 1; for (ll i = 2; i <= n; i++) res = res * i; return res;}
|
||||||
ll nPr(ll n, ll r) { return fact(n) / fact(n - r); }
|
ll nPr(ll n, ll r) { return fact(n) / fact(n - r); }
|
||||||
ll nCr(ll n, ll r) { return fact(n) / (fact(r) * fact(n - r)); }
|
ll nCr(ll n, ll r) { return fact(n) / (fact(r) * fact(n - r)); }
|
||||||
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
|
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
|
||||||
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b);}
|
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b);}
|
||||||
ll mypow(ll a, ll b){ ll ans = 1; while(b){ if (b&1) ans = (ans*a) ; b /= 2; a = (a*a); } return ans; }
|
ll mypow(ll a, ll b){ ll ans = 1; while(b){ if (b&1) ans = (ans*a) ; b /= 2; a = (a*a); } return ans; }
|
||||||
bool isPrime(ll n) { if(n <= 1) return false; for(ll i = 2; i <= sqrt(n); i++) if(n % i == 0) return false; return true;}
|
bool isPrime(ll n) { if(n <= 1) return false; for(ll i = 2; i <= sqrt(n); i++) if(n % i == 0) return false; return true;}
|
||||||
|
|
||||||
//////////////////////////////////Code Start/////////////////////////////////////
|
//////////////////////////////////Code Start/////////////////////////////////////
|
||||||
|
|
||||||
void solve()
|
void solve()
|
||||||
{
|
{
|
||||||
int n;
|
int n;
|
||||||
cin>>n;
|
cin>>n;
|
||||||
vector<int>v(n);
|
vector<int>v(n);
|
||||||
fr(n)
|
fr(n)
|
||||||
cin>>v[i];
|
cin>>v[i];
|
||||||
sort(all(v));
|
sort(all(v));
|
||||||
int diff=INT_MAX;
|
int diff=INT_MAX;
|
||||||
fro(n)
|
fro(n)
|
||||||
{
|
{
|
||||||
diff=min(v[i]-v[i-1],diff);
|
diff=min(v[i]-v[i-1],diff);
|
||||||
}
|
}
|
||||||
cout<<diff<<nl;
|
cout<<diff<<nl;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
fast_io;
|
fast_io;
|
||||||
int TC = 1;
|
int TC = 1;
|
||||||
cin >> TC;
|
cin >> TC;
|
||||||
while (TC--) solve();
|
while (TC--) solve();
|
||||||
}
|
}
|
@ -1,64 +1,64 @@
|
|||||||
#include<bits/stdc++.h>
|
#include<bits/stdc++.h>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
#define ll long long
|
#define ll long long
|
||||||
#define ul unsigned long long
|
#define ul unsigned long long
|
||||||
#define pb push_back
|
#define pb push_back
|
||||||
#define ss second
|
#define ss second
|
||||||
#define ff first
|
#define ff first
|
||||||
#define fr(m) for(int i=0; i<m; i++)
|
#define fr(m) for(int i=0; i<m; i++)
|
||||||
#define fro(m) for(int i=1; i<m; i++)
|
#define fro(m) for(int i=1; i<m; i++)
|
||||||
#define frj(m) for(int j=0; j<m; j++)
|
#define frj(m) for(int j=0; j<m; j++)
|
||||||
#define frr(n) for(int i=n; i>=0; i--)
|
#define frr(n) for(int i=n; i>=0; i--)
|
||||||
#define nl '\n'
|
#define nl '\n'
|
||||||
#define yes cout<<"YES"<<nl
|
#define yes cout<<"YES"<<nl
|
||||||
#define no cout<<"NO"<<nl
|
#define no cout<<"NO"<<nl
|
||||||
#define all(x) x.begin(), x.end()
|
#define all(x) x.begin(), x.end()
|
||||||
#define dbg(x) cerr << #x <<" "<< x << endl;
|
#define dbg(x) cerr << #x <<" "<< x << endl;
|
||||||
#define fast_io (ios_base:: sync_with_stdio(false),cin.tie(NULL));
|
#define fast_io (ios_base:: sync_with_stdio(false),cin.tie(NULL));
|
||||||
|
|
||||||
ll fact(ll n){ if(n==0) return 1; ll res = 1; for (ll i = 2; i <= n; i++) res = res * i; return res;}
|
ll fact(ll n){ if(n==0) return 1; ll res = 1; for (ll i = 2; i <= n; i++) res = res * i; return res;}
|
||||||
ll nPr(ll n, ll r) { return fact(n) / fact(n - r); }
|
ll nPr(ll n, ll r) { return fact(n) / fact(n - r); }
|
||||||
ll nCr(ll n, ll r) { return fact(n) / (fact(r) * fact(n - r)); }
|
ll nCr(ll n, ll r) { return fact(n) / (fact(r) * fact(n - r)); }
|
||||||
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
|
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
|
||||||
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b);}
|
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b);}
|
||||||
ll mypow(ll a, ll b){ ll ans = 1; while(b){ if (b&1) ans = (ans*a) ; b /= 2; a = (a*a); } return ans; }
|
ll mypow(ll a, ll b){ ll ans = 1; while(b){ if (b&1) ans = (ans*a) ; b /= 2; a = (a*a); } return ans; }
|
||||||
bool isPrime(ll n) { if(n <= 1) return false; for(ll i = 2; i <= sqrt(n); i++) if(n % i == 0) return false; return true;}
|
bool isPrime(ll n) { if(n <= 1) return false; for(ll i = 2; i <= sqrt(n); i++) if(n % i == 0) return false; return true;}
|
||||||
|
|
||||||
#define PI 3.141592653589793238;
|
#define PI 3.141592653589793238;
|
||||||
#define INF LONG_LONG_MAX;
|
#define INF LONG_LONG_MAX;
|
||||||
#define MOD 1e9+7;
|
#define MOD 1e9+7;
|
||||||
|
|
||||||
//////////////////////////////////Code Start/////////////////////////////////////
|
//////////////////////////////////Code Start/////////////////////////////////////
|
||||||
|
|
||||||
void solve()
|
void solve()
|
||||||
{
|
{
|
||||||
int n;
|
int n;
|
||||||
cin>>n;
|
cin>>n;
|
||||||
vector<int>v(n);
|
vector<int>v(n);
|
||||||
fr(n) cin>>v[i];
|
fr(n) cin>>v[i];
|
||||||
if(n==1)
|
if(n==1)
|
||||||
{
|
{
|
||||||
yes;
|
yes;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sort(all(v));
|
sort(all(v));
|
||||||
fro(n)
|
fro(n)
|
||||||
{
|
{
|
||||||
if(v[i]-v[i-1]>1)
|
if(v[i]-v[i-1]>1)
|
||||||
{
|
{
|
||||||
no;
|
no;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
yes;
|
yes;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
fast_io;
|
fast_io;
|
||||||
int TC = 1;
|
int TC = 1;
|
||||||
cin >> TC;
|
cin >> TC;
|
||||||
while (TC--) solve();
|
while (TC--) solve();
|
||||||
}
|
}
|
@ -1,52 +1,52 @@
|
|||||||
#include<bits/stdc++.h>
|
#include<bits/stdc++.h>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
#define ll long long
|
#define ll long long
|
||||||
#define ul unsigned long long
|
#define ul unsigned long long
|
||||||
#define pb push_back
|
#define pb push_back
|
||||||
#define ss second
|
#define ss second
|
||||||
#define ff first
|
#define ff first
|
||||||
#define fr(n) for(int i=0; i<n; i++)
|
#define fr(n) for(int i=0; i<n; i++)
|
||||||
#define fro(n) for(int i=1; i<n; i++)
|
#define fro(n) for(int i=1; i<n; i++)
|
||||||
#define frj(n) for(int j=0; j<n; j++)
|
#define frj(n) for(int j=0; j<n; j++)
|
||||||
#define frr(n) for(int i=n; i>=0; i--)
|
#define frr(n) for(int i=n; i>=0; i--)
|
||||||
#define nl '\n'
|
#define nl '\n'
|
||||||
#define yes cout<<"YES"<<nl
|
#define yes cout<<"YES"<<nl
|
||||||
#define no cout<<"NO"<<nl
|
#define no cout<<"NO"<<nl
|
||||||
#define all(x) x.begin(), x.end()
|
#define all(x) x.begin(), x.end()
|
||||||
#define dbg(x) cerr << #x <<" "<< x << endl;
|
#define dbg(x) cerr << #x <<" "<< x << endl;
|
||||||
#define fast_io (ios_base:: sync_with_stdio(false),cin.tie(NULL));
|
#define fast_io (ios_base:: sync_with_stdio(false),cin.tie(NULL));
|
||||||
|
|
||||||
#define PI 3.141592653589793238
|
#define PI 3.141592653589793238
|
||||||
#define INF LONG_LONG_MAX
|
#define INF LONG_LONG_MAX
|
||||||
#define MOD 1e9+7
|
#define MOD 1e9+7
|
||||||
|
|
||||||
ll fact(ll n){ if(n==0) return 1; ll res = 1; for (ll i = 2; i <= n; i++) res = res * i; return res;}
|
ll fact(ll n){ if(n==0) return 1; ll res = 1; for (ll i = 2; i <= n; i++) res = res * i; return res;}
|
||||||
ll nPr(ll n, ll r) { return fact(n) / fact(n - r); }
|
ll nPr(ll n, ll r) { return fact(n) / fact(n - r); }
|
||||||
ll nCr(ll n, ll r) { return fact(n) / (fact(r) * fact(n - r)); }
|
ll nCr(ll n, ll r) { return fact(n) / (fact(r) * fact(n - r)); }
|
||||||
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
|
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
|
||||||
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b);}
|
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b);}
|
||||||
ll mypow(ll a, ll b){ ll ans = 1; while(b){ if (b&1) ans = (ans*a) ; b /= 2; a = (a*a); } return ans; }
|
ll mypow(ll a, ll b){ ll ans = 1; while(b){ if (b&1) ans = (ans*a) ; b /= 2; a = (a*a); } return ans; }
|
||||||
bool isPrime(ll n) { if(n <= 1) return false; for(ll i = 2; i <= sqrt(n); i++) if(n % i == 0) return false; return true;}
|
bool isPrime(ll n) { if(n <= 1) return false; for(ll i = 2; i <= sqrt(n); i++) if(n % i == 0) return false; return true;}
|
||||||
|
|
||||||
//////////////////////////////////Code Start/////////////////////////////////////
|
//////////////////////////////////Code Start/////////////////////////////////////
|
||||||
|
|
||||||
void solve()
|
void solve()
|
||||||
{
|
{
|
||||||
string s;
|
string s;
|
||||||
cin>>s;
|
cin>>s;
|
||||||
for(auto &c:s)
|
for(auto &c:s)
|
||||||
c=tolower(c);
|
c=tolower(c);
|
||||||
if(s=="yes")
|
if(s=="yes")
|
||||||
yes;
|
yes;
|
||||||
else
|
else
|
||||||
no;
|
no;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
fast_io;
|
fast_io;
|
||||||
int TC = 1;
|
int TC = 1;
|
||||||
cin >> TC;
|
cin >> TC;
|
||||||
while (TC--) solve();
|
while (TC--) solve();
|
||||||
}
|
}
|
@ -1,47 +1,47 @@
|
|||||||
#include<bits/stdc++.h>
|
#include<bits/stdc++.h>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
#define ll long long
|
#define ll long long
|
||||||
#define ul unsigned long long
|
#define ul unsigned long long
|
||||||
#define pb push_back
|
#define pb push_back
|
||||||
#define ss second
|
#define ss second
|
||||||
#define ff first
|
#define ff first
|
||||||
#define fr(n) for(int i=0; i<n; i++)
|
#define fr(n) for(int i=0; i<n; i++)
|
||||||
#define fro(n) for(int i=1; i<n; i++)
|
#define fro(n) for(int i=1; i<n; i++)
|
||||||
#define frj(n) for(int j=0; j<n; j++)
|
#define frj(n) for(int j=0; j<n; j++)
|
||||||
#define frr(n) for(int i=n; i>=0; i--)
|
#define frr(n) for(int i=n; i>=0; i--)
|
||||||
#define nl '\n'
|
#define nl '\n'
|
||||||
#define yes cout<<"YES"<<nl
|
#define yes cout<<"YES"<<nl
|
||||||
#define no cout<<"NO"<<nl
|
#define no cout<<"NO"<<nl
|
||||||
#define all(x) x.begin(), x.end()
|
#define all(x) x.begin(), x.end()
|
||||||
#define dbg(x) cerr << #x <<" "<< x << endl;
|
#define dbg(x) cerr << #x <<" "<< x << endl;
|
||||||
#define fast_io (ios_base:: sync_with_stdio(false),cin.tie(NULL));
|
#define fast_io (ios_base:: sync_with_stdio(false),cin.tie(NULL));
|
||||||
|
|
||||||
#define PI 3.141592653589793238
|
#define PI 3.141592653589793238
|
||||||
#define INF LONG_LONG_MAX
|
#define INF LONG_LONG_MAX
|
||||||
#define MOD 1e9+7
|
#define MOD 1e9+7
|
||||||
|
|
||||||
ll fact(ll n){ if(n==0) return 1; ll res = 1; for (ll i = 2; i <= n; i++) res = res * i; return res;}
|
ll fact(ll n){ if(n==0) return 1; ll res = 1; for (ll i = 2; i <= n; i++) res = res * i; return res;}
|
||||||
ll nPr(ll n, ll r) { return fact(n) / fact(n - r); }
|
ll nPr(ll n, ll r) { return fact(n) / fact(n - r); }
|
||||||
ll nCr(ll n, ll r) { return fact(n) / (fact(r) * fact(n - r)); }
|
ll nCr(ll n, ll r) { return fact(n) / (fact(r) * fact(n - r)); }
|
||||||
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
|
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
|
||||||
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b);}
|
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b);}
|
||||||
ll mypow(ll a, ll b){ ll ans = 1; while(b){ if (b&1) ans = (ans*a) ; b /= 2; a = (a*a); } return ans; }
|
ll mypow(ll a, ll b){ ll ans = 1; while(b){ if (b&1) ans = (ans*a) ; b /= 2; a = (a*a); } return ans; }
|
||||||
bool isPrime(ll n) { if(n <= 1) return false; for(ll i = 2; i <= sqrt(n); i++) if(n % i == 0) return false; return true;}
|
bool isPrime(ll n) { if(n <= 1) return false; for(ll i = 2; i <= sqrt(n); i++) if(n % i == 0) return false; return true;}
|
||||||
|
|
||||||
//////////////////////////////////Code Start/////////////////////////////////////
|
//////////////////////////////////Code Start/////////////////////////////////////
|
||||||
|
|
||||||
void solve()
|
void solve()
|
||||||
{
|
{
|
||||||
ll n;
|
ll n;
|
||||||
cin>>n;
|
cin>>n;
|
||||||
cout<<n*(n+1)+n+2<<nl;
|
cout<<n*(n+1)+n+2<<nl;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
fast_io;
|
fast_io;
|
||||||
int TC = 1;
|
int TC = 1;
|
||||||
cin >> TC;
|
cin >> TC;
|
||||||
while (TC--) solve();
|
while (TC--) solve();
|
||||||
}
|
}
|
@ -1,50 +1,50 @@
|
|||||||
#include<bits/stdc++.h>
|
#include<bits/stdc++.h>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
#define ll long long
|
#define ll long long
|
||||||
#define ul unsigned long long
|
#define ul unsigned long long
|
||||||
#define pb push_back
|
#define pb push_back
|
||||||
#define ss second
|
#define ss second
|
||||||
#define ff first
|
#define ff first
|
||||||
#define fr(n) for(int i=0; i<n; i++)
|
#define fr(n) for(int i=0; i<n; i++)
|
||||||
#define fro(n) for(int i=1; i<n; i++)
|
#define fro(n) for(int i=1; i<n; i++)
|
||||||
#define frj(n) for(int j=0; j<n; j++)
|
#define frj(n) for(int j=0; j<n; j++)
|
||||||
#define frr(n) for(int i=n; i>=0; i--)
|
#define frr(n) for(int i=n; i>=0; i--)
|
||||||
#define nl '\n'
|
#define nl '\n'
|
||||||
#define yes cout<<"YES"<<nl
|
#define yes cout<<"YES"<<nl
|
||||||
#define no cout<<"NO"<<nl
|
#define no cout<<"NO"<<nl
|
||||||
#define all(x) x.begin(), x.end()
|
#define all(x) x.begin(), x.end()
|
||||||
#define dbg(x) cerr << #x <<" "<< x << endl;
|
#define dbg(x) cerr << #x <<" "<< x << endl;
|
||||||
#define fast_io (ios_base:: sync_with_stdio(false),cin.tie(NULL));
|
#define fast_io (ios_base:: sync_with_stdio(false),cin.tie(NULL));
|
||||||
|
|
||||||
#define PI 3.141592653589793238
|
#define PI 3.141592653589793238
|
||||||
#define INF LONG_LONG_MAX
|
#define INF LONG_LONG_MAX
|
||||||
#define MOD 1e9+7
|
#define MOD 1e9+7
|
||||||
|
|
||||||
ll fact(ll n){ if(n==0) return 1; ll res = 1; for (ll i = 2; i <= n; i++) res = res * i; return res;}
|
ll fact(ll n){ if(n==0) return 1; ll res = 1; for (ll i = 2; i <= n; i++) res = res * i; return res;}
|
||||||
ll nPr(ll n, ll r) { return fact(n) / fact(n - r); }
|
ll nPr(ll n, ll r) { return fact(n) / fact(n - r); }
|
||||||
ll nCr(ll n, ll r) { return fact(n) / (fact(r) * fact(n - r)); }
|
ll nCr(ll n, ll r) { return fact(n) / (fact(r) * fact(n - r)); }
|
||||||
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
|
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
|
||||||
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b);}
|
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b);}
|
||||||
ll mypow(ll a, ll b){ ll ans = 1; while(b){ if (b&1) ans = (ans*a) ; b /= 2; a = (a*a); } return ans; }
|
ll mypow(ll a, ll b){ ll ans = 1; while(b){ if (b&1) ans = (ans*a) ; b /= 2; a = (a*a); } return ans; }
|
||||||
bool isPrime(ll n) { if(n <= 1) return false; for(ll i = 2; i <= sqrt(n); i++) if(n % i == 0) return false; return true;}
|
bool isPrime(ll n) { if(n <= 1) return false; for(ll i = 2; i <= sqrt(n); i++) if(n % i == 0) return false; return true;}
|
||||||
|
|
||||||
//////////////////////////////////Code Start/////////////////////////////////////
|
//////////////////////////////////Code Start/////////////////////////////////////
|
||||||
|
|
||||||
void solve()
|
void solve()
|
||||||
{
|
{
|
||||||
int x,k;
|
int x,k;
|
||||||
cin>>x>>k;
|
cin>>x>>k;
|
||||||
if(x%k!=0)
|
if(x%k!=0)
|
||||||
cout<<1<<nl<<x<<nl;
|
cout<<1<<nl<<x<<nl;
|
||||||
else
|
else
|
||||||
cout<<2<<nl<<k+1<<" "<<x-k-1<<nl;
|
cout<<2<<nl<<k+1<<" "<<x-k-1<<nl;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
fast_io;
|
fast_io;
|
||||||
int TC = 1;
|
int TC = 1;
|
||||||
cin >> TC;
|
cin >> TC;
|
||||||
while (TC--) solve();
|
while (TC--) solve();
|
||||||
}
|
}
|
@ -1,63 +1,63 @@
|
|||||||
#include<bits/stdc++.h>
|
#include<bits/stdc++.h>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
#define ll long long
|
#define ll long long
|
||||||
#define ul unsigned long long
|
#define ul unsigned long long
|
||||||
#define pb push_back
|
#define pb push_back
|
||||||
#define ss second
|
#define ss second
|
||||||
#define ff first
|
#define ff first
|
||||||
#define fr(n) for(int i=0; i<n; i++)
|
#define fr(n) for(int i=0; i<n; i++)
|
||||||
#define fro(n) for(int i=1; i<n; i++)
|
#define fro(n) for(int i=1; i<n; i++)
|
||||||
#define frj(n) for(int j=0; j<n; j++)
|
#define frj(n) for(int j=0; j<n; j++)
|
||||||
#define frr(n) for(int i=n; i>=0; i--)
|
#define frr(n) for(int i=n; i>=0; i--)
|
||||||
#define nl '\n'
|
#define nl '\n'
|
||||||
#define yes cout<<"YES"<<nl
|
#define yes cout<<"YES"<<nl
|
||||||
#define no cout<<"NO"<<nl
|
#define no cout<<"NO"<<nl
|
||||||
#define all(x) x.begin(), x.end()
|
#define all(x) x.begin(), x.end()
|
||||||
#define dbg(x) cerr << #x <<" "<< x << endl;
|
#define dbg(x) cerr << #x <<" "<< x << endl;
|
||||||
#define fast_io (ios_base:: sync_with_stdio(false),cin.tie(NULL));
|
#define fast_io (ios_base:: sync_with_stdio(false),cin.tie(NULL));
|
||||||
|
|
||||||
#define PI 3.141592653589793238
|
#define PI 3.141592653589793238
|
||||||
#define INF LONG_LONG_MAX
|
#define INF LONG_LONG_MAX
|
||||||
#define MOD 1e9+7
|
#define MOD 1e9+7
|
||||||
|
|
||||||
ll fact(ll n){ if(n==0) return 1; ll res = 1; for (ll i = 2; i <= n; i++) res = res * i; return res;}
|
ll fact(ll n){ if(n==0) return 1; ll res = 1; for (ll i = 2; i <= n; i++) res = res * i; return res;}
|
||||||
ll nPr(ll n, ll r) { return fact(n) / fact(n - r); }
|
ll nPr(ll n, ll r) { return fact(n) / fact(n - r); }
|
||||||
ll nCr(ll n, ll r) { return fact(n) / (fact(r) * fact(n - r)); }
|
ll nCr(ll n, ll r) { return fact(n) / (fact(r) * fact(n - r)); }
|
||||||
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
|
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
|
||||||
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b);}
|
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b);}
|
||||||
ll mypow(ll a, ll b){ ll ans = 1; while(b){ if (b&1) ans = (ans*a) ; b /= 2; a = (a*a); } return ans; }
|
ll mypow(ll a, ll b){ ll ans = 1; while(b){ if (b&1) ans = (ans*a) ; b /= 2; a = (a*a); } return ans; }
|
||||||
bool isPrime(ll n) { if(n <= 1) return false; for(ll i = 2; i <= sqrt(n); i++) if(n % i == 0) return false; return true;}
|
bool isPrime(ll n) { if(n <= 1) return false; for(ll i = 2; i <= sqrt(n); i++) if(n % i == 0) return false; return true;}
|
||||||
|
|
||||||
//////////////////////////////////Code Start/////////////////////////////////////
|
//////////////////////////////////Code Start/////////////////////////////////////
|
||||||
|
|
||||||
void solve()
|
void solve()
|
||||||
{
|
{
|
||||||
int n,k;
|
int n,k;
|
||||||
cin>>n>>k;
|
cin>>n>>k;
|
||||||
vector<int>v(n);
|
vector<int>v(n);
|
||||||
fr(n) cin>>v[i];
|
fr(n) cin>>v[i];
|
||||||
int mx=0,ct=1;
|
int mx=0,ct=1;
|
||||||
sort(all(v));
|
sort(all(v));
|
||||||
fro(n)
|
fro(n)
|
||||||
{
|
{
|
||||||
int d=v[i]-v[i-1];
|
int d=v[i]-v[i-1];
|
||||||
if(d<=k)
|
if(d<=k)
|
||||||
ct++;
|
ct++;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mx=max(mx,ct);
|
mx=max(mx,ct);
|
||||||
ct=1;
|
ct=1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mx=max(mx,ct);
|
mx=max(mx,ct);
|
||||||
cout<<n-mx<<nl;
|
cout<<n-mx<<nl;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
fast_io;
|
fast_io;
|
||||||
int TC = 1;
|
int TC = 1;
|
||||||
cin >> TC;
|
cin >> TC;
|
||||||
while (TC--) solve();
|
while (TC--) solve();
|
||||||
}
|
}
|
@ -1,57 +1,57 @@
|
|||||||
#include<bits/stdc++.h>
|
#include<bits/stdc++.h>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
#define ll long long
|
#define ll long long
|
||||||
#define ul unsigned long long
|
#define ul unsigned long long
|
||||||
#define pb push_back
|
#define pb push_back
|
||||||
#define ss second
|
#define ss second
|
||||||
#define ff first
|
#define ff first
|
||||||
#define fr(n) for(int i=0; i<n; i++)
|
#define fr(n) for(int i=0; i<n; i++)
|
||||||
#define fro(n) for(int i=1; i<n; i++)
|
#define fro(n) for(int i=1; i<n; i++)
|
||||||
#define frj(n) for(int j=0; j<n; j++)
|
#define frj(n) for(int j=0; j<n; j++)
|
||||||
#define frr(n) for(int i=n; i>=0; i--)
|
#define frr(n) for(int i=n; i>=0; i--)
|
||||||
#define nl '\n'
|
#define nl '\n'
|
||||||
#define yes cout<<"YES"<<nl
|
#define yes cout<<"YES"<<nl
|
||||||
#define no cout<<"NO"<<nl
|
#define no cout<<"NO"<<nl
|
||||||
#define all(x) x.begin(), x.end()
|
#define all(x) x.begin(), x.end()
|
||||||
#define dbg(x) cerr << #x <<" "<< x << endl;
|
#define dbg(x) cerr << #x <<" "<< x << endl;
|
||||||
#define fast_io (ios_base:: sync_with_stdio(false),cin.tie(NULL));
|
#define fast_io (ios_base:: sync_with_stdio(false),cin.tie(NULL));
|
||||||
|
|
||||||
#define PI 3.141592653589793238
|
#define PI 3.141592653589793238
|
||||||
#define INF LONG_LONG_MAX
|
#define INF LONG_LONG_MAX
|
||||||
#define MOD 1e9+7
|
#define MOD 1e9+7
|
||||||
|
|
||||||
ll fact(ll n){ if(n==0) return 1; ll res = 1; for (ll i = 2; i <= n; i++) res = res * i; return res;}
|
ll fact(ll n){ if(n==0) return 1; ll res = 1; for (ll i = 2; i <= n; i++) res = res * i; return res;}
|
||||||
ll nPr(ll n, ll r) { return fact(n) / fact(n - r); }
|
ll nPr(ll n, ll r) { return fact(n) / fact(n - r); }
|
||||||
ll nCr(ll n, ll r) { return fact(n) / (fact(r) * fact(n - r)); }
|
ll nCr(ll n, ll r) { return fact(n) / (fact(r) * fact(n - r)); }
|
||||||
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
|
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
|
||||||
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b);}
|
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b);}
|
||||||
ll mypow(ll a, ll b){ ll ans = 1; while(b){ if (b&1) ans = (ans*a) ; b /= 2; a = (a*a); } return ans; }
|
ll mypow(ll a, ll b){ ll ans = 1; while(b){ if (b&1) ans = (ans*a) ; b /= 2; a = (a*a); } return ans; }
|
||||||
bool isPrime(ll n) { if(n <= 1) return false; for(ll i = 2; i <= sqrt(n); i++) if(n % i == 0) return false; return true;}
|
bool isPrime(ll n) { if(n <= 1) return false; for(ll i = 2; i <= sqrt(n); i++) if(n % i == 0) return false; return true;}
|
||||||
|
|
||||||
//////////////////////////////////Code Start/////////////////////////////////////
|
//////////////////////////////////Code Start/////////////////////////////////////
|
||||||
|
|
||||||
void solve()
|
void solve()
|
||||||
{
|
{
|
||||||
int n;
|
int n;
|
||||||
cin>>n;
|
cin>>n;
|
||||||
int sum=0;
|
int sum=0;
|
||||||
fr(n)
|
fr(n)
|
||||||
{
|
{
|
||||||
int x;
|
int x;
|
||||||
cin>>x;
|
cin>>x;
|
||||||
sum+=x;
|
sum+=x;
|
||||||
}
|
}
|
||||||
if(sum&1)
|
if(sum&1)
|
||||||
no;
|
no;
|
||||||
else
|
else
|
||||||
yes;
|
yes;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
fast_io;
|
fast_io;
|
||||||
int TC = 1;
|
int TC = 1;
|
||||||
cin >> TC;
|
cin >> TC;
|
||||||
while (TC--) solve();
|
while (TC--) solve();
|
||||||
}
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user