Skip to content

Commit c44faad

Browse files
committed
update
1 parent 0cdfbb4 commit c44faad

38 files changed

+1077
-15
lines changed

.classpath

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77
</classpathentry>
88
<classpathentry kind="src" path="src"/>
99
<classpathentry kind="src" path="CSES/Introductory Problems"/>
10+
<classpathentry kind="src" path="heisenburg2.0"/>
1011
<classpathentry kind="output" path="bin"/>
1112
</classpath>
991 Bytes
Binary file not shown.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import java.io.BufferedReader;
2+
import java.io.IOException;
3+
import java.io.InputStreamReader;
4+
5+
6+
public class Dice_Combinations {
7+
8+
public static void main(String[] args)throws IOException {
9+
10+
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
11+
int n=Integer.parseInt(br.readLine());
12+
13+
int dp[]= new int[n+1];
14+
dp[0]=1;
15+
dp[1]=1;
16+
int k=6;
17+
18+
dp[0]=dp[1]=1;
19+
20+
for(int i=2;i<=k;i++)
21+
dp[i] = 2*dp[i-1];
22+
23+
for(int i=k+1;i<=n;i++)
24+
dp[i] = 2*dp[i-1]-dp[i-k-1];
25+
26+
System.out.println(dp[n]);
27+
}
28+
}
29+

heisenburg2.0/Vacc_permutation.cpp

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#include <bits/stdc++.h>
2+
#define ll long long
3+
#define MOD 1000000007
4+
#define M 1001
5+
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);
6+
#define w(t) ll t;cin >> t;while (t--)
7+
//#define sort(a) sort(a.begin(), a.end());
8+
using namespace std;
9+
10+
ll a[M], pows[M], c[M][M];
11+
// void hk(){
12+
// #ifndef ONLINE_JUDGE
13+
// freopen("input49.txt", "r", stdin);
14+
// freopen("output49.txt", "w", stdout);
15+
// #endif
16+
// }
17+
18+
int main()
19+
{
20+
fastIO;
21+
22+
memset(a, 0, sizeof(a));
23+
memset(c, 0, sizeof(c));
24+
memset(pows, 0, sizeof(pows));
25+
26+
pows[0] = 1;
27+
pows[1] = 1;
28+
29+
30+
for (ll i = 2; i <= 1000; i++)
31+
{
32+
pows[i] = (pows[i - 1] * 2) % MOD;
33+
}
34+
35+
36+
37+
c[0][0] = 1;
38+
for (int i = 1; i <= 1000; i++)
39+
{
40+
c[i][0] = 1;
41+
for (int j = 1; j <= i; j++)
42+
{
43+
c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % MOD;
44+
}
45+
}
46+
47+
48+
ll m, n;
49+
cin >> n >> m;
50+
51+
for (ll i = 1; i <= m; i++)
52+
{
53+
cin >> a[i];
54+
}
55+
56+
sort(a + 1, a + m + 1);
57+
58+
ll sum = 1;
59+
ll d = n - m;
60+
61+
for (int i = 1; i <= m; i++)
62+
{
63+
sum = (sum * c[d][a[i] - a[i - 1] - 1]) % MOD;
64+
d -= a[i] - a[i - 1] - 1;
65+
}
66+
67+
for (int i = 2; i <= m; i++)
68+
{
69+
sum = (sum * pows[a[i] - a[i - 1] - 1]) % MOD;
70+
}
71+
72+
73+
cout << sum << "\n";
74+
75+
return 0;
76+
}

heisenburg2.0/a.out

48.2 KB
Binary file not shown.

heisenburg2.0/cd.cpp

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#include <bits/stdc++.h>
2+
#define ll long long
3+
#define pb emplace_back
4+
#define fr first
5+
#define sc second
6+
#define endl "\n"
7+
using namespace std;
8+
int main(){
9+
ios_base::sync_with_stdio(false);
10+
cin.tie(NULL);
11+
ll t;
12+
cin >> t;
13+
while(t--){
14+
ll a, b;
15+
cin >> a >> b;
16+
string s;
17+
cin >> s;
18+
if(count(s.begin() , s.end() , '0') == s.size()){
19+
cout << "0" << endl;
20+
continue;
21+
}
22+
int m = 0 , d = -1 , i = 0 , c , n = s.size();
23+
while( i < n ){
24+
c = 0;
25+
int st = i;
26+
27+
while(s[i%n] == '0'){
28+
c++;
29+
i++;
30+
}
31+
if(c > m){
32+
m = c;
33+
d = st;
34+
}
35+
i++;
36+
}
37+
38+
ll ans = a;
39+
c = 0;
40+
if(m == 0){
41+
cout << ans << endl;
42+
continue;
43+
}
44+
c= 0;
45+
for(int i = m + d; (i)%n != d;i++){
46+
if(s[i%n]=='0'){
47+
c++;
48+
} else {
49+
ans = ans + min(c*b , a);
50+
c = 0;
51+
}
52+
}
53+
54+
cout << ans << endl;
55+
}
56+
return 0;
57+
}

heisenburg2.0/circdom.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
for _ in range(int(input())):
2+
ab=list(map(int,input().split()))
3+
a,b=ab[0],ab[1]
4+
s=list(map(int,input()))
5+
n=len(s)
6+
v=[]
7+
for i in range(n):
8+
if s[i] == 0:
9+
if i == 0 or s[i-1] == 1:
10+
v.append(0)
11+
v[-1]=v[-1]+1
12+
13+
if len(v)==1 and v[0]==n:
14+
print(0)
15+
continue
16+
17+
ans=a
18+
19+
if v!=[]:
20+
if s[0] == 0 and s[n-1] == 0:
21+
n = v[-1]
22+
v.pop(-1)
23+
24+
if v==[]:
25+
v.append(n)
26+
else:
27+
v[0]=v[0]+n
28+
sorted(v)
29+
v.pop(-1)
30+
n=len(v)
31+
for i in range(n):
32+
ans+=min(b*v[i],a)
33+
print(ans)
34+
35+
36+
37+
38+
39+
2.9 KB
Binary file not shown.
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
2+
import java.io.*;
3+
import java.util.*;
4+
5+
public class circular_dominos {
6+
static BufferedReader __in = new BufferedReader(new InputStreamReader(System.in));
7+
static PrintWriter __out = new PrintWriter(new OutputStreamWriter(System.out));
8+
static StringTokenizer input;
9+
static final int IBIG = 1000000007;
10+
11+
static String rline() throws IOException {return __in.readLine();}
12+
static int ri() throws IOException {return Integer.parseInt(rline());}
13+
static void r() throws IOException {input = new StringTokenizer(rline());}
14+
static String n() {return input.nextToken();}
15+
static int rni() throws IOException {r(); return ni();}
16+
static int ni() {return Integer.parseInt(n());}
17+
static char[] rcha() throws IOException {return rline().toCharArray();}
18+
static void prln(int i) {__out.println(i);}
19+
static void close() {__out.close();}
20+
public static void main(String[] args) throws IOException {
21+
int t = ri();
22+
while (t --> 0) {
23+
int a = rni(), b = ni();
24+
String s=rline();
25+
int n = s.length();
26+
int i = 0;
27+
28+
List<Integer> v = new ArrayList<>();
29+
30+
for(i=0; i<n; i++)
31+
{
32+
if(s.charAt(i) == '0')
33+
{
34+
if(i == 0 || s.charAt(i-1) == '1')
35+
{
36+
v.add(0);
37+
}
38+
v.set(v.size()-1,v.get(v.size()-1)+1);
39+
40+
}
41+
}
42+
43+
44+
45+
if(v.size() == 1 && v.get(0) == n)
46+
{
47+
prln(0);
48+
continue;
49+
}
50+
51+
int ans = a;
52+
if(v.isEmpty()==false)
53+
{
54+
if(s.charAt(0) == '0' && s.charAt(n-1) == '0')
55+
{
56+
n = v.get(v.size()-1);
57+
v.remove(v.size() - 1);
58+
59+
if(v.isEmpty())
60+
{
61+
v.add(n);
62+
}
63+
else
64+
{
65+
v.set(0,v.get(0)+n);
66+
}
67+
}
68+
69+
Collections.sort(v);
70+
71+
v.remove(v.size() - 1);
72+
73+
n=v.size();
74+
75+
for(i=0; i<n; i++)
76+
{
77+
ans+=Math.min(b*v.get(i),a);
78+
}
79+
}
80+
prln(ans);
81+
}
82+
close();
83+
}
84+
85+
}
86+
2.21 KB
Binary file not shown.

0 commit comments

Comments
 (0)