Skip to content

Commit e5dc859

Browse files
committed
contest leetcode, atcoder
1 parent bd7eaec commit e5dc859

14 files changed

+1443
-30
lines changed
+133
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
/*
2+
written by Pankaj Kumar.
3+
country:-INDIA
4+
*/
5+
#include <bits/stdc++.h>
6+
#include <ext/pb_ds/assoc_container.hpp>
7+
#include <ext/pb_ds/tree_policy.hpp>
8+
using namespace std;
9+
using namespace __gnu_pbds;
10+
typedef long long ll ;
11+
typedef vector<ll> vl;
12+
typedef vector<vector<ll>> vvl;
13+
#define speed cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
14+
/* Abbrevations */
15+
#define ff first
16+
#define ss second
17+
#define mp make_pair
18+
#define line cout<<endl;
19+
#define pb push_back
20+
// Some print
21+
#define no cout<<"NO"<<endl;
22+
#define yes cout<<"YES"<<endl;
23+
// sort
24+
#define all(V) (V).begin(),(V).end()
25+
#define srt(V) sort(all(V))
26+
#define srtGreat(V) sort(all(V),greater<ll>())
27+
// some extra
28+
#define printv(v) for(ll i=0;i<ll(v.size());i++){cout<<v[i]<<" ";} line;
29+
#define precision(x) cout<<fixed<<setprecision(x);
30+
#define sz(V) ll(V.size())
31+
// datatype definination
32+
#define ordered_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
33+
34+
35+
class Atcoder{
36+
private:
37+
// read only variable
38+
const ll INF=1e18;
39+
const ll mod1=1e9+7;
40+
const ll mod2=998244353;
41+
42+
43+
public:
44+
Atcoder(){
45+
46+
}
47+
48+
ll power(ll x,ll y){
49+
ll result=1;
50+
while(y>0){
51+
if(y&1){
52+
result*=x;
53+
}
54+
y>>=1;
55+
x*=x;
56+
}
57+
return result;
58+
}
59+
60+
ll power(ll x,ll y,ll mod){
61+
ll result=1;
62+
x%=mod;
63+
while(y>0){
64+
if(y&1){
65+
result*=x;
66+
result%=mod;
67+
}
68+
y>>=1;
69+
x*=x;
70+
x%=mod;
71+
}
72+
return result;
73+
}
74+
75+
ll str_to_num(string s)
76+
{
77+
stringstream pk(s);
78+
ll num;
79+
pk>>num;
80+
return num;
81+
}
82+
83+
string num_to_str(ll num){
84+
return to_string(num);
85+
}
86+
// Techniques :
87+
// divide into cases, brute force, pattern finding
88+
// sort, greedy, binary search, two pointer
89+
// transform into graph
90+
91+
// Experience :
92+
// Cp is nothing but only observation and mathematics.
93+
ll solve(){
94+
string s;
95+
cin>>s;
96+
srt(s);
97+
for(int i=0;i<sz(s);i++){
98+
int x=s[i]-'0';
99+
if(x!=i){
100+
cout<<i<<endl;
101+
return 0;
102+
}
103+
}
104+
cout<<9<<endl;
105+
return 0;
106+
}
107+
};
108+
109+
110+
/* --------------------MAIN PROGRAM----------------------------*/
111+
112+
int main()
113+
{
114+
speed;
115+
/* #ifndef ONLINE_JUDGE
116+
freopen("input.txt","r",stdin);
117+
freopen("output.txt","w",stdout);
118+
#endif */
119+
ll TestCase=1;
120+
// cin>>TestCase;;
121+
while(TestCase--){
122+
Atcoder at;
123+
at.solve();
124+
}
125+
}
126+
/* -----------------END OF PROGRAM --------------------*/
127+
/*
128+
* stuff you should look before submission
129+
* constraint and time limit
130+
* int overflow
131+
* special test case (n=0||n=1||n=2)
132+
* don't get stuck on one approach if you get wrong answer
133+
*/

Atcoder/ABC/abc248_B-Slimes.cpp

+131
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
/*
2+
written by Pankaj Kumar.
3+
country:-INDIA
4+
*/
5+
#include <bits/stdc++.h>
6+
#include <ext/pb_ds/assoc_container.hpp>
7+
#include <ext/pb_ds/tree_policy.hpp>
8+
using namespace std;
9+
using namespace __gnu_pbds;
10+
typedef long long ll ;
11+
typedef vector<ll> vl;
12+
typedef vector<vector<ll>> vvl;
13+
#define speed cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
14+
/* Abbrevations */
15+
#define ff first
16+
#define ss second
17+
#define mp make_pair
18+
#define line cout<<endl;
19+
#define pb push_back
20+
// Some print
21+
#define no cout<<"NO"<<endl;
22+
#define yes cout<<"YES"<<endl;
23+
// sort
24+
#define all(V) (V).begin(),(V).end()
25+
#define srt(V) sort(all(V))
26+
#define srtGreat(V) sort(all(V),greater<ll>())
27+
// some extra
28+
#define printv(v) for(ll i=0;i<ll(v.size());i++){cout<<v[i]<<" ";} line;
29+
#define precision(x) cout<<fixed<<setprecision(x);
30+
#define sz(V) ll(V.size())
31+
// datatype definination
32+
#define ordered_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
33+
34+
35+
class Atcoder{
36+
private:
37+
// read only variable
38+
const ll INF=1e18;
39+
const ll mod1=1e9+7;
40+
const ll mod2=998244353;
41+
42+
43+
public:
44+
Atcoder(){
45+
46+
}
47+
48+
ll power(ll x,ll y){
49+
ll result=1;
50+
while(y>0){
51+
if(y&1){
52+
result*=x;
53+
}
54+
y>>=1;
55+
x*=x;
56+
}
57+
return result;
58+
}
59+
60+
ll power(ll x,ll y,ll mod){
61+
ll result=1;
62+
x%=mod;
63+
while(y>0){
64+
if(y&1){
65+
result*=x;
66+
result%=mod;
67+
}
68+
y>>=1;
69+
x*=x;
70+
x%=mod;
71+
}
72+
return result;
73+
}
74+
75+
ll str_to_num(string s)
76+
{
77+
stringstream pk(s);
78+
ll num;
79+
pk>>num;
80+
return num;
81+
}
82+
83+
string num_to_str(ll num){
84+
return to_string(num);
85+
}
86+
// Techniques :
87+
// divide into cases, brute force, pattern finding
88+
// sort, greedy, binary search, two pointer
89+
// transform into graph
90+
91+
// Experience :
92+
// Cp is nothing but only observation and mathematics.
93+
ll solve(){
94+
ll a,b,k;
95+
cin>>a>>b>>k;
96+
ll ans=0;
97+
while(a<b){
98+
a*=k;
99+
ans++;
100+
}
101+
cout<<ans<<endl;
102+
103+
return 0;
104+
}
105+
};
106+
107+
108+
/* --------------------MAIN PROGRAM----------------------------*/
109+
110+
int main()
111+
{
112+
speed;
113+
/* #ifndef ONLINE_JUDGE
114+
freopen("input.txt","r",stdin);
115+
freopen("output.txt","w",stdout);
116+
#endif */
117+
ll TestCase=1;
118+
// cin>>TestCase;;
119+
while(TestCase--){
120+
Atcoder at;
121+
at.solve();
122+
}
123+
}
124+
/* -----------------END OF PROGRAM --------------------*/
125+
/*
126+
* stuff you should look before submission
127+
* constraint and time limit
128+
* int overflow
129+
* special test case (n=0||n=1||n=2)
130+
* don't get stuck on one approach if you get wrong answer
131+
*/

0 commit comments

Comments
 (0)