Skip to content

Commit 68641ce

Browse files
committed
29-07-2020
1 parent 24d74ff commit 68641ce

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+1847770
-86
lines changed

.vscode/launch.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "(gdb) Launch",
9+
"type": "cppdbg",
10+
"request": "launch",
11+
"program": "enter program name, for example ${workspaceFolder}/a.out",
12+
"args": [],
13+
"stopAtEntry": false,
14+
"cwd": "${workspaceFolder}",
15+
"environment": [],
16+
"externalConsole": false,
17+
"MIMode": "gdb",
18+
"setupCommands": [
19+
{
20+
"description": "Enable pretty-printing for gdb",
21+
"text": "-enable-pretty-printing",
22+
"ignoreFailures": true
23+
}
24+
]
25+
}
26+
]
27+
}

.vscode/settings.json

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,29 @@
2121
"limits": "cpp",
2222
"cmath": "cpp",
2323
"complex": "cpp",
24-
"ostream": "cpp"
24+
"ostream": "cpp",
25+
"atomic": "cpp",
26+
"condition_variable": "cpp",
27+
"cwchar": "cpp",
28+
"exception": "cpp",
29+
"iterator": "cpp",
30+
"functional": "cpp",
31+
"fstream": "cpp",
32+
"future": "cpp",
33+
"iosfwd": "cpp",
34+
"istream": "cpp",
35+
"mutex": "cpp",
36+
"new": "cpp",
37+
"ratio": "cpp",
38+
"scoped_allocator": "cpp",
39+
"shared_mutex": "cpp",
40+
"sstream": "cpp",
41+
"stdexcept": "cpp",
42+
"streambuf": "cpp",
43+
"thread": "cpp",
44+
"tuple": "cpp",
45+
"type_traits": "cpp",
46+
"typeindex": "cpp"
2547
},
2648
"competitive-programming-helper.firstTime": false
2749
}

414B.cpp

Lines changed: 36 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -50,38 +50,46 @@
5050
`''''`'''i==_+=_=i__
5151
||'''- ' `.
5252
`-.......-''
53-
*/
54-
#include<bits/stdc++.h>
53+
*/
54+
#include <bits/stdc++.h>
5555
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--)
56+
57+
#define fastio \
58+
ios_base::sync_with_stdio(0); \
59+
cin.tie(0)
60+
#define LL long long
61+
#define mod 1000000007
62+
#define FOR(i, j, k) for (auto i = j; i < k; i++)
63+
#define ROF(i, j, k) for (auto i = j; i >= k; i--)
6264
#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))
65+
#define time__(d) for (long blockTime = 0; (blockTime == 0 ? (blockTime = clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
6466

6567
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; vector<vector<int>>dp(n+1,vector<int>(k+1,0));
72-
// FOR(i,1,n+1) dp[1][i] = 1 + dp[1][i-1];
73-
// FOR(i,1,k+1) dp[i][1] = 1;
74-
FOR(i,1,n+1){
75-
FOR(j,1,k+1){
76-
dp[i][j] = dp[i-1][j];
77-
for(int f=1; f*f<i;f++) {
78-
if(i%f==0)
79-
dp[i][j]=(dp[i][j]+dp[f][j]+1)%mod,
80-
dp[i][j]=(dp[i][j]+dp[i/f][j]+1)%mod;
81-
}
82-
// dp[i][j]++;
83-
}
68+
const long long MAX = 1e5 + 10;
69+
int main()
70+
{
71+
fastio;
72+
int t = 1; // cin>>t;
73+
while (t--)
74+
{
75+
int n, k;
76+
cin >> n >> k;
77+
vector<vector<int>> dp(k + 1, vector<int>(n + 1, 0));
78+
FOR(i, 1, n + 1)
79+
dp[1][i] = 1;
80+
FOR(i, 2, k + 1)
81+
{
82+
FOR(j, 1, n + 1)
83+
{
84+
for (int f = j; f <= n; f += j)
85+
{
86+
dp[i][j] = (dp[i][j] + dp[i - 1][f]) % mod;
8487
}
85-
cout<<dp[n][k];
88+
}
8689
}
90+
LL ans = 0;
91+
FOR(i, 1, n + 1)
92+
ans = (ans + dp[k][i]) % mod;
93+
cout << ans;
94+
}
8795
}

510B.cpp

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
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 all(v) v.begin(),v.end()
61+
#define FOR(i, j, k) for (auto i=j ; i<k ; i++)
62+
#define ROF(i, j, k) for (auto i=j ; i>=k ; i--)
63+
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
64+
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
65+
66+
const long long INF = 1e18;
67+
const long long MAX = 1e5+10;
68+
bool vis[100][100];int n,m; bool pos = false;
69+
void dfs(int i,int j,vector<string>&s,int cnt,char ch,int r,int c){
70+
if(i<0 || j<0 || j>=m || i>=n || s[i][j]!=ch) return ;
71+
if(cnt>3 && vis[i][j]) {pos = 1; return;}
72+
if(vis[i][j]) return;
73+
74+
vis[i][j]=1; cnt++;
75+
if((i+1)!=r || j!=c) dfs(i+1,j,s,cnt+1,ch,i,j);
76+
if((i-1)!=r || j!=c) dfs(i-1,j,s,cnt+1,ch,i,j);
77+
if(i!=r || (j+1)!=c) dfs(i,j+1,s,cnt+1,ch,i,j);
78+
if(i!=r || (j-1)!=c) dfs(i,j-1,s,cnt+1,ch,i,j);
79+
80+
}
81+
int main(){
82+
fastio;
83+
int t=1;// cin>>t;
84+
while(t--){
85+
cin>>n>>m; vector<string>ch(n);
86+
FOR(i,0,n) cin>>ch[i];
87+
memset(vis,0,sizeof(vis));
88+
FOR(i,0,n) FOR(j,0,m) {
89+
if(!vis[i][j]) dfs(i,j,ch,0,ch[i][j],-1,-1);
90+
if(pos) {cout<<"Yes"; return 0;};
91+
}
92+
cout<<"No";
93+
}
94+
}

584D.cpp

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
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 all(v) v.begin(),v.end()
61+
#define FOR(i, j, k) for (auto i=j ; i<k ; i++)
62+
#define ROF(i, j, k) for (auto i=j ; i>=k ; i--)
63+
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
64+
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
65+
66+
const long long INF = 1e18;
67+
const long long MAX = 1e6+10;
68+
bool prime[MAX];
69+
70+
void Si(){
71+
memset(prime, true, sizeof(prime));
72+
for (int p=2; p*p<MAX; p++)
73+
if (prime[p] == true)
74+
for (int i=p*p; i<MAX; i += p)
75+
prime[i] = false;
76+
}
77+
int main(){
78+
fastio;
79+
int t=1;// cin>>t;
80+
Si();
81+
while(t--){
82+
int n; cin>>n;
83+
int cnt = 0;
84+
for(int i = 2; i*i<=n ;i++) if(n%i==0) cnt++;
85+
if(cnt==0) {cout<<1<<"\n"<<n; return 0;}
86+
if(n==4) {cout<<2<<"\n"<<2<<" "<<2; return 0;}
87+
if(n==6) {cout<<2<<"\n"<<3<<" "<<3; return 0;}
88+
cout<<3<<"\n"<<3<<" ";
89+
n-=3;
90+
FOR(i,2,MAX) {
91+
if(prime[i] && (n-i > 0 && n-i<MAX && prime[n-i]) ) {cout<<i<<" "<<n-i; break;}
92+
int s=n-i;
93+
bool sol =false;
94+
if(!prime[i]) continue;
95+
FOR(j,2,MAX) {
96+
if(s%j==0 && prime[j]) break;
97+
if(prime[j] && j*j>s) {cout<<i<<" "<<s; sol=true; break;}
98+
}
99+
if(sol) break;
100+
}
101+
}
102+
}

0 commit comments

Comments
 (0)