Skip to content

Commit 22ebe12

Browse files
committed
jul 13 2020 -- solved none -- mood off
1 parent 9c3b93c commit 22ebe12

File tree

17 files changed

+1172
-76
lines changed

17 files changed

+1172
-76
lines changed

0.cpp

Lines changed: 141 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,141 @@
1-
// C++ program to build the smallest number by removing n digits from
2-
// a given number
3-
#include<iostream>
4-
#include<vector>
5-
using namespace std;
6-
7-
// A recursive function that removes 'n' characters from 'str'
8-
// to store the smallest possible number in 'res'
9-
void buildLowestNumberRec(string str, int n, string &res)
10-
{
11-
// If there are 0 characters to remove from str,
12-
// append everything to result
13-
if (n == 0)
14-
{
15-
res.append(str);
16-
return;
17-
}
18-
19-
int len = str.length();
20-
21-
// If there are more characters to remove than string
22-
// length, then append nothing to result
23-
if (len <= n)
24-
return;
25-
26-
// Find the smallest character among first (n+1) characters
27-
// of str.
28-
int minIndex = 0;
29-
for (int i = 1; i<=n ; i++)
30-
if (str[i] < str[minIndex])
31-
minIndex = i;
32-
33-
// Append the smallest character to result
34-
res.push_back(str[minIndex]);
35-
36-
// substring starting from minIndex+1 to str.length() - 1.
37-
string new_str = str.substr(minIndex+1, len-minIndex);
38-
39-
// Recur for the above substring and n equals to n-minIndex
40-
buildLowestNumberRec(new_str, n-minIndex, res);
41-
}
42-
43-
// A wrapper over buildLowestNumberRec()
44-
string buildLowestNumber(string str, int n)
45-
{
46-
string res = "";
47-
48-
// Note that result is passed by reference
49-
buildLowestNumberRec(str, n, res);
50-
51-
return res;
52-
}
53-
54-
// Driver program to test above function
55-
int main()
56-
{ vector<int>v; v.push_back(NULL);
57-
string str = "987654321";
58-
int n = 2;
59-
cout << buildLowestNumber(str, n);
60-
return 0;
61-
}
1+
// // C++ program to build the smallest number by removing n digits from
2+
// // a given number
3+
// #include<iostream>
4+
// #include<vector>
5+
// using namespace std;
6+
7+
// // A recursive function that removes 'n' characters from 'str'
8+
// // to store the smallest possible number in 'res'
9+
// void buildLowestNumberRec(string str, int n, string &res)
10+
// {
11+
// // If there are 0 characters to remove from str,
12+
// // append everything to result
13+
// if (n == 0)
14+
// {
15+
// res.append(str);
16+
// return;
17+
// }
18+
19+
// int len = str.length();
20+
21+
// // If there are more characters to remove than string
22+
// // length, then append nothing to result
23+
// if (len <= n)
24+
// return;
25+
26+
// // Find the smallest character among first (n+1) characters
27+
// // of str.
28+
// int minIndex = 0;
29+
// for (int i = 1; i<=n ; i++)
30+
// if (str[i] < str[minIndex])
31+
// minIndex = i;
32+
33+
// // Append the smallest character to result
34+
// res.push_back(str[minIndex]);
35+
36+
// // substring starting from minIndex+1 to str.length() - 1.
37+
// string new_str = str.substr(minIndex+1, len-minIndex);
38+
39+
// // Recur for the above substring and n equals to n-minIndex
40+
// buildLowestNumberRec(new_str, n-minIndex, res);
41+
// }
42+
43+
// // A wrapper over buildLowestNumberRec()
44+
// string buildLowestNumber(string str, int n)
45+
// {
46+
// string res = "";
47+
48+
// // Note that result is passed by reference
49+
// buildLowestNumberRec(str, n, res);
50+
51+
// return res;
52+
// }
53+
54+
// // Driver program to test above function
55+
// int main()
56+
// { vector<int>v; v.push_back(NULL);
57+
// string str = "987654321";
58+
// int n = 2;
59+
// cout << buildLowestNumber(str, n);
60+
// return 0;
61+
// }
62+
63+
/* |\ | | ||\ \ /(_~ |~)|_~|\/||_~|\/||~)|_~|~)
64+
|~\|_|/\||~\ | ,_) |~\|__| ||__| ||_)|__|~\
65+
66+
\ //~\| | |\ |~)|_~ | ||\ ||/~\| ||_~
67+
| \_/\_/ |~\|~\|__ \_/| \||\_X\_/|__
68+
(J U S T L I K E E V E R Y O N E E L S E !)
69+
70+
__ ,..---.._
71+
+''''`--''-..`--..__
72+
.\ _,/:i--._`:-:+._`.``-._
73+
/`.._,,' \ `-.``--:.b....=.
74+
|`..__,,..`. '`.__::i--.-::_
75+
)- .....--i'\.. --+`'''-'
76+
,' .'.._,.-'|._-b\
77+
/,'<' V `oi| \ _.
78+
|/ -|,--.." ,'-. ||\.. _.,;:'_<'
79+
''/ | . ' |\||'\ /-'_/' `.
80+
|,','| , . .-.|:.`. + .,:.. |
81+
._,:'/ /-\ '^' -Y"\ |.| || /,+8d| |
82+
.|/,'| |/':: ':=:' ,'| | | \|| "+)=' |
83+
|+,';' /|_/ \ _/ \b':.\ \'| .|| ,'
84+
,,:-i''_i' | ``-.Y',. ,|`: | \;- | |_,'
85+
__ |'| |i:'._ ,' ,' ,; | |-)-' __--:b__
86+
.P| | |/,'|\ - ._ / / _,Y- ,:/' `. `'".._
87+
,'|| -','' | ._i._ `':| ,..,' ,Y;' \ `- ._
88+
|||||,.. | \ '-.._ _,' / _,b-' `. '-.
89+
||||P..i, .| '....,-' _,'''''-''' ' _,.. `\
90+
+'` <'/ |`-.....---' ._ ,._
91+
| | ,'``,:-''''/,--`.
92+
Y|.b_,,: | || ,;,Y' / |.
93+
,' /'----' .'| .. | | '" .`Y' .,-b_....;;,.
94+
|+|,' | | \., ' ,' `:. _ ,/__` _=: _,'``-
95+
/ +,' | /\_........:.' '"----:::::'Y .'.| |||
96+
|' ' .'/- \ /'|| || | |||
97+
||| /| \L /'|| ||/ | |||
98+
`.| ,'/ .| / ,'||/o;/ |||
99+
`..._,, | |/| ' |||
100+
``-' | |, |||
101+
| ,. | |||
102+
,=--------.... | "" | |||
103+
,/,'. i=..+._ ,.. '..;---:::''- | |
104+
'/| __....b `-''`---....../.,Y'''''j:.,.._ | `._
105+
.' _.Y.-' `.. ii:,'--------' | :-+. .| | b\
106+
| .=_,.---'''''--...:..--:' / _..-----..:= | | '|\
107+
| '-''`'--- ---'_,,,--'' `,.. | | \.
108+
\ . ,' _,--'' :dg: _,/ ||| | \
109+
`::b\` _,-i,-' ,..---' ,|:| | _|
110+
`'--.:-._ ____,,,;.,'' `--._ '''''''' |'|' .' '
111+
``'--....Y''-' `''--..._..____._____...,' | 'o-'
112+
`''''`'''i==_+=_=i__
113+
||'''- ' `.
114+
`-.......-''
115+
*/
116+
#include<bits/stdc++.h>
117+
using namespace std;
118+
119+
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
120+
#define LL long long
121+
#define mod 1000000007
122+
#define FOR(i, j, k) for (auto i=j ; i<k ; i++)
123+
#define ROF(i, j, k) for (auto i=j ; i>=k ; i--)
124+
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
125+
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
126+
127+
const long long INF = 1e18;
128+
const long long MAX = 1e5+10;
129+
int main(){
130+
fastio;
131+
int t=1;// cin>>t;
132+
while(t--){
133+
int n; cin>>n;
134+
for (int i = 1; i*i <= n; i++)
135+
{
136+
/* code */
137+
if(n%i == 0) cout<<i<<" "<<n/i<<"; ";
138+
}
139+
140+
}
141+
}

1015B.cpp

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
/* |\ | | ||\ \ /(_~ |~)|_~|\/||_~|\/||~)|_~|~)
2+
|~\|_|/\||~\ | ,_) |~\|__| ||__| ||_)|__|~\
3+
4+
\ //~\| | |\ |~)|_~ | ||\ ||/~\| ||_~
5+
| \_/\_/ |~\|~\|__ \_/| \||\_X\_/|__
6+
(J U S T L I K E E V E R Y O N E E L S E !)
7+
8+
__ ,..---.._
9+
+''''`--''-..`--..__
10+
.\ _,/:i--._`:-:+._`.``-._
11+
/`.._,,' \ `-.``--:.b....=.
12+
|`..__,,..`. '`.__::i--.-::_
13+
)- .....--i'\.. --+`'''-'
14+
,' .'.._,.-'|._-b\
15+
/,'<' V `oi| \ _.
16+
|/ -|,--.." ,'-. ||\.. _.,;:'_<'
17+
''/ | . ' |\||'\ /-'_/' `.
18+
|,','| , . .-.|:.`. + .,:.. |
19+
._,:'/ /-\ '^' -Y"\ |.| || /,+8d| |
20+
.|/,'| |/':: ':=:' ,'| | | \|| "+)=' |
21+
|+,';' /|_/ \ _/ \b':.\ \'| .|| ,'
22+
,,:-i''_i' | ``-.Y',. ,|`: | \;- | |_,'
23+
__ |'| |i:'._ ,' ,' ,; | |-)-' __--:b__
24+
.P| | |/,'|\ - ._ / / _,Y- ,:/' `. `'".._
25+
,'|| -','' | ._i._ `':| ,..,' ,Y;' \ `- ._
26+
|||||,.. | \ '-.._ _,' / _,b-' `. '-.
27+
||||P..i, .| '....,-' _,'''''-''' ' _,.. `\
28+
+'` <'/ |`-.....---' ._ ,._
29+
| | ,'``,:-''''/,--`.
30+
Y|.b_,,: | || ,;,Y' / |.
31+
,' /'----' .'| .. | | '" .`Y' .,-b_....;;,.
32+
|+|,' | | \., ' ,' `:. _ ,/__` _=: _,'``-
33+
/ +,' | /\_........:.' '"----:::::'Y .'.| |||
34+
|' ' .'/- \ /'|| || | |||
35+
||| /| \L /'|| ||/ | |||
36+
`.| ,'/ .| / ,'||/o;/ |||
37+
`..._,, | |/| ' |||
38+
``-' | |, |||
39+
| ,. | |||
40+
,=--------.... | "" | |||
41+
,/,'. i=..+._ ,.. '..;---:::''- | |
42+
'/| __....b `-''`---....../.,Y'''''j:.,.._ | `._
43+
.' _.Y.-' `.. ii:,'--------' | :-+. .| | b\
44+
| .=_,.---'''''--...:..--:' / _..-----..:= | | '|\
45+
| '-''`'--- ---'_,,,--'' `,.. | | \.
46+
\ . ,' _,--'' :dg: _,/ ||| | \
47+
`::b\` _,-i,-' ,..---' ,|:| | _|
48+
`'--.:-._ ____,,,;.,'' `--._ '''''''' |'|' .' '
49+
``'--....Y''-' `''--..._..____._____...,' | 'o-'
50+
`''''`'''i==_+=_=i__
51+
||'''- ' `.
52+
`-.......-''
53+
*/
54+
#include<bits/stdc++.h>
55+
using namespace std;
56+
57+
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
58+
#define LL long long
59+
#define mod 1000000007
60+
#define FOR(i, j, k) for (auto i=j ; i<k ; i++)
61+
#define ROF(i, j, k) for (auto i=j ; i>=k ; i--)
62+
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
63+
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
64+
65+
const long long INF = 1e18;
66+
const long long MAX = 1e5+10;
67+
int main(){
68+
fastio;
69+
int t=1;// cin>>t;
70+
while(t--){
71+
int n; cin>>n; string s,t; cin>>s>>t; vector<int>res;
72+
FOR(i,0,n) {
73+
if(s[i]==t[i]) continue;
74+
int k =-1;
75+
FOR(j,i+1,n) if(s[j]==t[i]) {k=j; break;}
76+
if(k==-1) {cout<<-1; return 0;}
77+
while(k>i) res.push_back(k),swap(s[k],s[k-1]),k--;
78+
}
79+
cout<<res.size()<<"\n";
80+
for(auto i : res) cout<<i<<" ";
81+
}
82+
}

110.cpp

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/* |\ | | ||\ \ /(_~ |~)|_~|\/||_~|\/||~)|_~|~)
2+
|~\|_|/\||~\ | ,_) |~\|__| ||__| ||_)|__|~\
3+
4+
\ //~\| | |\ |~)|_~ | ||\ ||/~\| ||_~
5+
| \_/\_/ |~\|~\|__ \_/| \||\_X\_/|__
6+
(J U S T L I K E E V E R Y O N E E L S E !)
7+
8+
__ ,..---.._
9+
+''''`--''-..`--..__
10+
.\ _,/:i--._`:-:+._`.``-._
11+
/`.._,,' \ `-.``--:.b....=.
12+
|`..__,,..`. '`.__::i--.-::_
13+
)- .....--i'\.. --+`'''-'
14+
,' .'.._,.-'|._-b\
15+
/,'<' V `oi| \ _.
16+
|/ -|,--.." ,'-. ||\.. _.,;:'_<'
17+
''/ | . ' |\||'\ /-'_/' `.
18+
|,','| , . .-.|:.`. + .,:.. |
19+
._,:'/ /-\ '^' -Y"\ |.| || /,+8d| |
20+
.|/,'| |/':: ':=:' ,'| | | \|| "+)=' |
21+
|+,';' /|_/ \ _/ \b':.\ \'| .|| ,'
22+
,,:-i''_i' | ``-.Y',. ,|`: | \;- | |_,'
23+
__ |'| |i:'._ ,' ,' ,; | |-)-' __--:b__
24+
.P| | |/,'|\ - ._ / / _,Y- ,:/' `. `'".._
25+
,'|| -','' | ._i._ `':| ,..,' ,Y;' \ `- ._
26+
|||||,.. | \ '-.._ _,' / _,b-' `. '-.
27+
||||P..i, .| '....,-' _,'''''-''' ' _,.. `\
28+
+'` <'/ |`-.....---' ._ ,._
29+
| | ,'``,:-''''/,--`.
30+
Y|.b_,,: | || ,;,Y' / |.
31+
,' /'----' .'| .. | | '" .`Y' .,-b_....;;,.
32+
|+|,' | | \., ' ,' `:. _ ,/__` _=: _,'``-
33+
/ +,' | /\_........:.' '"----:::::'Y .'.| |||
34+
|' ' .'/- \ /'|| || | |||
35+
||| /| \L /'|| ||/ | |||
36+
`.| ,'/ .| / ,'||/o;/ |||
37+
`..._,, | |/| ' |||
38+
``-' | |, |||
39+
| ,. | |||
40+
,=--------.... | "" | |||
41+
,/,'. i=..+._ ,.. '..;---:::''- | |
42+
'/| __....b `-''`---....../.,Y'''''j:.,.._ | `._
43+
.' _.Y.-' `.. ii:,'--------' | :-+. .| | b\
44+
| .=_,.---'''''--...:..--:' / _..-----..:= | | '|\
45+
| '-''`'--- ---'_,,,--'' `,.. | | \.
46+
\ . ,' _,--'' :dg: _,/ ||| | \
47+
`::b\` _,-i,-' ,..---' ,|:| | _|
48+
`'--.:-._ ____,,,;.,'' `--._ '''''''' |'|' .' '
49+
``'--....Y''-' `''--..._..____._____...,' | 'o-'
50+
`''''`'''i==_+=_=i__
51+
||'''- ' `.
52+
`-.......-''
53+
*/
54+
#include<bits/stdc++.h>
55+
using namespace std;
56+
57+
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
58+
#define LL long long
59+
#define mod 1000000007
60+
#define FOR(i, j, k) for (auto i=j ; i<k ; i++)
61+
#define ROF(i, j, k) for (auto i=j ; i>=k ; i--)
62+
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
63+
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
64+
65+
const long long INF = 1e18;
66+
const long long MAX = 1e5+10;
67+
int main(){
68+
fastio;
69+
int t=1;// cin>>t;
70+
while(t--){
71+
int n,k; cin>>n>>k;
72+
ROF(i,k+1,1) cout<<i<<" ";
73+
FOR(i,k+2,n+1) cout<<i<<" ";
74+
}
75+
}
76+

0 commit comments

Comments
 (0)