Skip to content

Commit

Permalink
file uploads
Browse files Browse the repository at this point in the history
  • Loading branch information
nayandeep20028840 committed Aug 23, 2023
1 parent ae44f02 commit c22e06a
Show file tree
Hide file tree
Showing 862 changed files with 41,959 additions and 638 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"name":"Local: 1","url":"c:\\Users\\varsh\\.vscode\\nayan work c c++\\Codeforces_Problem_Solving_2\\Problem A\\A. Buying Torches\\1.cpp","tests":[{"id":1692543556035,"input":"5\n2 1 5\n42 13 24\n12 11 12\n1000000000 1000000000 1000000000\n2 1000000000 1000000000","output":"14\n33\n25\n2000000003\n1000000001999999999"}],"interactive":false,"memoryLimit":1024,"timeLimit":3000,"srcPath":"c:\\Users\\varsh\\.vscode\\nayan work c c++\\Codeforces_Problem_Solving_2\\Problem A\\A. Buying Torches\\1.cpp","group":"local","local":true}
Binary file not shown.
111 changes: 111 additions & 0 deletions Codeforces_Problem_Solving/A_Problems/A. Buying Torches/1.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
#include<bits/stdc++.h>
using namespace std;

// Policy based data structures(PBDS) C++ STL
// find_by_order(k): returns the iterator of the k-th element in a set (0-index)
// order_of_key(k): returns count of elements strictly smaller than k
// Time complexity: O(logn) for both
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; // for pairs only define simply by ordered_set s
typedef tree<pair<int, int>, null_type, less_equal<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;
template<class T>using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update> ; // here T can be anything like pair,vector,map,pair_of_pair // USE it like Tree<pair<int,int>> s; for pairs

#ifndef ONLINE_JUDGE
#define debug(x) cerr << #x <<" "; _print(x); cerr << endl;
#else
#define debug(x)
#endif

void _print(long long t) {cerr << t;}
void _print(string t) {cerr << t;}
void _print(char t) {cerr << t;}
void _print(long double t) {cerr << t;}

template <class T, class V> void _print(pair <T, V> p) {cerr << "{"; _print(p.first); cerr << ","; _print(p.second); cerr << "}";}
template <class T> void _print(vector <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(set <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(multiset <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T, class V> void _print(map <T, V> v) {cerr << "[ "; for (auto i : v) {_print(i); cerr << " ";} cerr << "]";}

#define ll long long // typedef array<int, 2> ii; pair h ye
#define int ll
#define ld long double
#define iv(a , n) vector<int>a(n); for(int i=0;i<n;++i){cin>>a[i];}
#define yes cout << "YES" << endl;
#define no cout << "NO" << endl;
#define all(v) v.begin(),v.end()
#define F first
#define S second
#define check1(v) for(auto &i : v){ cout<<i<<" "; } cout<<endl;
#define check2(v) for(auto &i : v){ cout<<i.F<<" "<<i.S<<endl; }
#define check3(v) for(auto &i : v){ cout<<i.F.F<<" "<<i.F.S<<" "<<i.S<<endl; }
#define check4(v) for(auto &i : v){ cout<<i.F.F<<" "<<i.F.S<<" "<<i.S.F<<" "<<i.S.S<<endl; }
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define bpp __builtin_popcountll
#define INF 1000000000000000000
#define Pi 3.1415926535897932384626
#define EPS 1e-9
#define nl "\n"

const int mod97 = 1000000007 ;
const int modg = 998244353 ;
const int N = 2e1 + 1 ;
const int LOG = 21 ;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()) ; // a random number generator (RNG) using the Mersenne Twister algorithm, specifically the mt19937 engine. The purpose of an RNG is to generate a sequence of random numbers.

int GCD(int a, int b){if(b == 0){return a;} return GCD(b, a % b);} // Euclidean algorithm for computing the greatest common divisor
int LCM(int a, int b){return (a / GCD(a, b) * b) ;}
int mod_ADDITION(int a, int b, int m) {a = a % m; b = b % m; return (((a + b) % m) + m) % m;}
int mod_MULTIPLICATION(int a, int b, int m) {a = a % m; b = b % m; return (((a * b) % m) + m) % m;}
int mod_SUBTRACTION(int a, int b, int m) {a = a % m; b = b % m; return (((a - b) % m) + m) % m;}
bool comparatorfunction(pair<int,int> &a, pair<int,int> &b){if(a.S != b.S){return a.S < b.S ;}return a.F > b.F ;}
int power(int x, int y){int res = 1 ; while(y > 0) {if(y & 1) res = (res * x) ; x = (x * x) ; y = y >> 1 ;} return res ;}
int modpower(int x, int y){int res = 1; x = x % mod97; while(y > 0){if(y&1) res = (res * x) % mod97; y = y >> 1; x = (x * x) % mod97 ;}return res ;}
bool isPowerOfTwo(int n){if(n==0) {return false;} return (ceil(log2(n)) == floor(log2(n)));}
vector<int > giveme_it_isprime_or_not(int n){vector<int > isPrime(n+1, 1);isPrime[0]=isPrime[1]=false;for(int i = 2; i <= n; ++i){if(isPrime[i] == true){for(int j = 2*i; j <= n; j += i){isPrime[j] = false;}}} return isPrime;}
vector<int> givemeprimes(int n) {int*arr = new int[n + 1](); vector<int> vect; for(int i = 2; i <= n; i++)if (arr[i] == 0) {vect.push_back(i); for(int j = i * i; j <= n; j += i)arr[j] = 1;} return vect;}
vector<vector<int>> givemedivisors(int n){int*arr = new int[n + 1]();vector<vector<int > > vect(n + 1);for(int i = 2; i <= n; ++i){if(arr[i] == 0){for(int j = i; j <= n; j += i){vect[j].pb(i);arr[i] = 1;}}} return vect ;}
vector<int > givemesmallestprimefactors(int n){vector<int > SPF(n + 1);for(int i = 0; i <= n; ++i){SPF[i] = i;}for(int i = 2; i <= n; ++i){if(SPF[i] == i){for(int j = i; j <= n; j += i){if(SPF[j] == j){SPF[j] = i;}}}}return SPF ;} // SPF is the smallest prime number that divides a given number without leaving a remainder
int sqrtprecision(int l,int r,int target){while(r-l>EPS){int mid=(l+(r-l)/2);if(mid*mid<target)l=mid;else r=mid;}return l+(r-l)/2;}
void ncrwithoutmod(int n, int r){long long p = 1, k = 1; if (n-r < r) r = n-r; if (r != 0) {while (r) {p *= n; k *= r; long long m = __gcd(p, k);p /= m; k /= m; n--; r--; }} else cout << p << endl; }
int getRandomNumber(int l, int r) {return uniform_int_distribution<int>(l, r)(rng);}

bool solve(){
int x , y , k ;
cin >> x >> y >> k ;
int t = k * y + k ;
cout << k + ( (t + (x - 1) - 1 - 1) / (x - 1) ) << nl ;
return true ;
}


int32_t main()
{
ios_base::sync_with_stdio(false); cin.tie(NULL);
//#ifndef ONLINE_JUDGE
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
// freopen("error.txt", "w", stderr);
//#endif
int t;
cin >> t;
//int count = 1;

while (t--){
//cout << "Case #" << count << ": ";
if(solve()){
//count++;
}else{
// no
}
}
return 0;
}



// Talk is Cheap. Show me the code
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"name":"Local: 1","url":"c:\\Users\\varsh\\.vscode\\nayan work c c++\\Codeforces_Problem_Solving_2\\Problem A\\A. Cubes Sorting\\1.cpp","tests":[{"id":1690687556101,"input":"3\n5\n5 3 2 1 4\n6\n2 2 2 2 2 2\n2\n2 1","output":"YES\nYES\nNO"}],"interactive":false,"memoryLimit":1024,"timeLimit":3000,"srcPath":"c:\\Users\\varsh\\.vscode\\nayan work c c++\\Codeforces_Problem_Solving_2\\Problem A\\A. Cubes Sorting\\1.cpp","group":"local","local":true}
Binary file not shown.
124 changes: 124 additions & 0 deletions Codeforces_Problem_Solving/A_Problems/A. Cubes Sorting/1.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
#include<bits/stdc++.h>
using namespace std;

// Policy based data structures(PBDS) C++ STL
// find_by_order(k): returns the iterator of the k-th element in a set (0-index)
// order_of_key(k): returns count of elements strictly smaller than k
// Time complexity: O(logn) for both
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; // for pairs only define simply by ordered_set s
typedef tree<pair<int, int>, null_type, less_equal<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;
template<class T>using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update> ; // here T can be anything like pair,vector,map,pair_of_pair // USE it like Tree<pair<int,int>> s; for pairs

#ifndef ONLINE_JUDGE
#define debug(x) cerr << #x <<" "; _print(x); cerr << endl;
#else
#define debug(x)
#endif

void _print(long long t) {cerr << t;}
void _print(string t) {cerr << t;}
void _print(char t) {cerr << t;}
void _print(long double t) {cerr << t;}

template <class T, class V> void _print(pair <T, V> p) {cerr << "{"; _print(p.first); cerr << ","; _print(p.second); cerr << "}";}
template <class T> void _print(vector <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(set <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(multiset <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T, class V> void _print(map <T, V> v) {cerr << "[ "; for (auto i : v) {_print(i); cerr << " ";} cerr << "]";}

#define ll long long // typedef array<int, 2> ii; pair h ye
#define int ll
#define ld long double
#define iv(a , n) vector<int>a(n); for(int i=0;i<n;++i){cin>>a[i];}
#define yes cout << "YES" << endl;
#define no cout << "NO" << endl;
#define all(v) v.begin(),v.end()
#define F first
#define S second
#define check1(v) for(auto &i : v){ cout<<i<<" "; } cout<<endl;
#define check2(v) for(auto &i : v){ cout<<i.F<<" "<<i.S<<endl; }
#define check3(v) for(auto &i : v){ cout<<i.F.F<<" "<<i.F.S<<" "<<i.S<<endl; }
#define check4(v) for(auto &i : v){ cout<<i.F.F<<" "<<i.F.S<<" "<<i.S.F<<" "<<i.S.S<<endl; }
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define bpp __builtin_popcountll
#define INF 1000000000000000000
#define Pi 3.1415926535897932384626
#define EPS 1e-9
#define nl "\n"

const int mod97 = 1000000007 ;
const int modg = 998244353 ;
const int N = 2e1 + 1 ;
const int LOG = 21 ;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()) ; // a random number generator (RNG) using the Mersenne Twister algorithm, specifically the mt19937 engine. The purpose of an RNG is to generate a sequence of random numbers.

int GCD(int a, int b){if(b == 0){return a;} return GCD(b, a % b);} // Euclidean algorithm for computing the greatest common divisor
int LCM(int a, int b){return (a / GCD(a, b) * b) ;}
int mod_ADDITION(int a, int b, int m) {a = a % m; b = b % m; return (((a + b) % m) + m) % m;}
int mod_MULTIPLICATION(int a, int b, int m) {a = a % m; b = b % m; return (((a * b) % m) + m) % m;}
int mod_SUBTRACTION(int a, int b, int m) {a = a % m; b = b % m; return (((a - b) % m) + m) % m;}
bool comparatorfunction(pair<int,int> &a, pair<int,int> &b){if(a.S != b.S){return a.S < b.S ;}return a.F > b.F ;}
int power(int x, int y){int res = 1 ; while(y > 0) {if(y & 1) res = (res * x) ; x = (x * x) ; y = y >> 1 ;} return res ;}
int modpower(int x, int y){int res = 1; x = x % mod97; while(y > 0){if(y&1) res = (res * x) % mod97; y = y >> 1; x = (x * x) % mod97 ;}return res ;}
bool isPowerOfTwo(int n){if(n==0) {return false;} return (ceil(log2(n)) == floor(log2(n)));}
vector<int > giveme_it_isprime_or_not(int n){vector<int > isPrime(n+1, 1);isPrime[0]=isPrime[1]=false;for(int i = 2; i <= N; ++i){if(isPrime[i] == true){for(int j = 2*i; j <= N; j += i){isPrime[j] = false;}}} return isPrime;}
vector<int> givemeprimes(int n) {int*arr = new int[n + 1](); vector<int> vect; for(int i = 2; i <= n; i++)if (arr[i] == 0) {vect.push_back(i); for(int j = i * i; j <= n; j += i)arr[j] = 1;} return vect;}
vector<vector<int>> givemedivisors(int n){int*arr = new int[n + 1]();vector<vector<int > > vect(n + 1);for(int i = 2; i <= n; ++i){if(arr[i] == 0){for(int j = i; j <= n; j += i){vect[j].pb(i);arr[i] = 1;}}} return vect ;}
vector<int > givemesmallestprimefactors(int n){vector<int > SPF(n + 1);for(int i = 0; i <= N; ++i){SPF[i] = i;}for(int i = 2; i <= N; ++i){if(SPF[i] == i){for(int j = i; j <= N; j += i){if(SPF[j] == j){SPF[j] = i;}}}}return SPF ;} // SPF is the smallest prime number that divides a given number without leaving a remainder
int sqrtprecision(int l,int r,int target){while(r-l>EPS){int mid=(l+(r-l)/2);if(mid*mid<target)l=mid;else r=mid;}return l+(r-l)/2;}
void ncrwithoutmod(int n, int r){long long p = 1, k = 1; if (n-r < r) r = n-r; if (r != 0) {while (r) {p *= n; k *= r; long long m = __gcd(p, k);p /= m; k /= m; n--; r--; }} else cout << p << endl; }
int getRandomNumber(int l, int r) {return uniform_int_distribution<int>(l, r)(rng);}

bool solve(){
int n ;
cin >> n ;
iv(v , n)
vector<int > vv = v ;
sort(all(vv)) ;
reverse(all(vv)) ;
int j = n ;
int f = 0 ;
for(int i = 0 ; i < n ; ++i){
if(v[i] != vv[i] || v[i] < j){
f = 1 ;
break ;
}
j -= 1 ;
}
if(f) yes
else no
return true ;
}


int32_t main()
{
ios_base::sync_with_stdio(false); cin.tie(NULL);
//#ifndef ONLINE_JUDGE
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
// freopen("error.txt", "w", stderr);
//#endif
int t;
cin >> t;
//int count = 1;

while (t--){
//cout << "Case #" << count << ": ";
if(solve()){
//count++;
}else{
// no
}
}
return 0;
}



// Don't overthink and try to prove your idea.
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
#include<bits/stdc++.h>
using namespace std;

// Policy based data structures(PBDS) C++ STL
// order_of_key(k): returns count of elements strictly smaller than k
// find_by_order(k): returns the iterator of the k-th element in a set (0-index)
// Time complexity: O(logn) for both
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#ifndef ONLINE_JUDGE
#define debug(x) cerr << #x <<" "; _print(x); cerr << endl;
#else
#define debug(x)
#endif

void _print(long long t) {cerr << t;}
void _print(string t) {cerr << t;}
void _print(char t) {cerr << t;}
void _print(long double t) {cerr << t;}

template <class T, class V> void _print(pair <T, V> p) {cerr << "{"; _print(p.first); cerr << ","; _print(p.second); cerr << "}";}
template <class T> void _print(vector <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(set <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(multiset <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T, class V> void _print(map <T, V> v) {cerr << "[ "; for (auto i : v) {_print(i); cerr << " ";} cerr << "]";}

#define ll long long
#define int ll
#define ld long double
#define iv(a , n) vector<int>a(n); for(int i=0;i<n;++i){cin>>a[i];}
#define yes cout << "YES" << endl;
#define no cout << "NO" << endl;
#define all(v) v.begin(),v.end()
#define F first
#define S second
#define check1(v) for(auto &i : v){ cout<<i<<" "; } cout<<endl;
#define check2(v) for(auto &i : v){ cout<<i.F<<" "<<i.S<<endl; }
#define check3(v) for(auto &i : v){ cout<<i.F.F<<" "<<i.F.S<<" "<<i.S<<endl; }
#define check4(v) for(auto &i : v){ cout<<i.F.F<<" "<<i.F.S<<" "<<i.S.F<<" "<<i.S.S<<endl; }
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define bpp __builtin_popcountll
#define INF 1000000000000000000
#define Pi 3.1415926535897932384626
#define EPS 1e-9
#define nl "\n"

const int mod97 = 1000000007 ;
const int modg = 998244353 ;
const int N = 2e1 + 10 ;
int SPF[N] ;
vector<bool > isPrime(N , 1) ;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()) ; // a random number generator (RNG) using the Mersenne Twister algorithm, specifically the mt19937 engine. The purpose of an RNG is to generate a sequence of random numbers.

int gcd(int a, int b){if(b == 0){return a;} return gcd(b, a % b);}
int lcm(int a, int b){return (a / gcd(a, b) * b) ;}
bool comparatorfunction(pair<int,int> &a, pair<int,int> &b){if(a.S != b.S){return a.S < b.S ;}return a.F > b.F ;}
int power(int x, int y){int res = 1 ; while(y > 0) {if(y & 1) res = (res * x) ; x = (x * x) ; y = y >> 1 ;} return res ;}
int powermod(int x, int y){int res = 1; x = x % mod97; while(y > 0){if(y&1) res = (res * x) % mod97; y = y >> 1; x = (x * x) % mod97 ;}return res ;}
bool isPowerOfTwo(int n){if(n==0) {return false;} return (ceil(log2(n)) == floor(log2(n)));}
void prime(){isPrime[0]=isPrime[1]=false;for(int i = 2; i <= N; ++i){if(isPrime[i] == true){for(int j = 2*i; j <= N; j += i){isPrime[j] = false;}}}}
void spf(){for(int i = 0; i <= N; ++i) SPF[i] = i; for(int i = 2; i <= N; ++i) if(SPF[i] == i) for(int j = i; j <= N; j += i) if(SPF[j] == j) SPF[j] = i;} // SPF is the smallest prime number that divides a given number without leaving a remainder
int isqrt(int n){long long x = sqrtl(n);while (x*x>n){--x;} while((x+1) * (x+1)<=n){++x;}return x;}
int sqrtprecision(int l,int r,int target){while(r-l>EPS){int mid=(l+(r-l)/2);if(mid*mid<target)l=mid;else r=mid;}return l+(r-l)/2;}
int errichtokabinary(int l,int r,vector<int>&a,int target){int ans=-1; while(l <= r){int mid=(l+(r-l)/2); if(a[mid]==target){ans=mid;return ans;}if(a[mid]<target)l=mid+1;else r=mid-1;}return ans;}
void ncrwithoutmod(int n, int r){long long p = 1, k = 1; if (n-r < r) r = n-r; if (r != 0) {while (r) {p *= n; k *= r; long long m = __gcd(p, k);p /= m; k /= m; n--; r--; }} else cout << p << endl; }
int getRandomNumber(int l, int r) {return uniform_int_distribution<int>(l, r)(rng);}

bool solve(){
int n ;
cin >> n ;
iv(v , n)
sort(all(v)) ;
int cnt = 0 ;
for(int i = 1 ; i < n - 1 ; ++i){
if(v[i] < v[n - 1] && v[i] > v[0]){
cnt += 1 ;
}
}
cout << cnt << nl ;
return true;
}


int32_t main()
{
ios_base::sync_with_stdio(false); cin.tie(NULL);
//#ifndef ONLINE_JUDGE
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
// freopen("error.txt", "w", stderr);
//#endif
int t = 1;
//cin >> t;
//int count = 1;

while (t--){
//cout << "Case #" << count << ": ";
if(solve()){
//count++;
}else{
// cout << "NO" << endl;
}
}
return 0;
}





Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"name":"Local: 1","url":"c:\\Users\\varsh\\.vscode\\nayan work c c++\\Codeforces_Problem_Solving_2\\Problem A\\A. Power Of Two\\1.cpp","tests":[{"id":1689323870290,"input":"8","output":""},{"id":1689323873262,"input":"10","output":""}],"interactive":false,"memoryLimit":1024,"timeLimit":3000,"srcPath":"c:\\Users\\varsh\\.vscode\\nayan work c c++\\Codeforces_Problem_Solving_2\\Problem A\\A. Power Of Two\\1.cpp","group":"local","local":true}
Binary file not shown.
Loading

0 comments on commit c22e06a

Please sign in to comment.