Skip to content

Commit 9d7f685

Browse files
Number of People Aware of Scerets
1 parent 15dcda1 commit 9d7f685

File tree

2 files changed

+114
-0
lines changed

2 files changed

+114
-0
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"id": "5a801d74",
6+
"metadata": {},
7+
"source": [
8+
"# Number of People Aware of Scerets"
9+
]
10+
},
11+
{
12+
"cell_type": "code",
13+
"execution_count": null,
14+
"id": "f247f0fd",
15+
"metadata": {},
16+
"outputs": [],
17+
"source": [
18+
"n = 6 \n",
19+
"delay = 2\n",
20+
"forget = 4\n",
21+
"\n",
22+
"Mod = 10**9+7\n",
23+
"\n",
24+
"dp = [0] * (n+1)\n",
25+
"dp[1] = 1\n",
26+
"\n",
27+
"for i in range(1, n+1):\n",
28+
" for j in range(i+delay, min(i+forget, n+1)):\n",
29+
" dp[j] = (dp[j]+dp[i])%Mod\n",
30+
"\n",
31+
"ans = 0\n",
32+
"for i in range(n-forget+1, n+1):\n",
33+
" ans = (ans+dp[i])%Mod\n",
34+
"\n",
35+
"ans\n",
36+
"dp"
37+
]
38+
}
39+
],
40+
"metadata": {
41+
"kernelspec": {
42+
"display_name": "Python 3",
43+
"language": "python",
44+
"name": "python3"
45+
},
46+
"language_info": {
47+
"codemirror_mode": {
48+
"name": "ipython",
49+
"version": 3
50+
},
51+
"file_extension": ".py",
52+
"mimetype": "text/x-python",
53+
"name": "python",
54+
"nbconvert_exporter": "python",
55+
"pygments_lexer": "ipython3",
56+
"version": "3.13.3"
57+
}
58+
},
59+
"nbformat": 4,
60+
"nbformat_minor": 5
61+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"id": "0e3ae9c8",
6+
"metadata": {},
7+
"source": [
8+
"# Minimum Operation To Make Integer Zero"
9+
]
10+
},
11+
{
12+
"cell_type": "code",
13+
"execution_count": null,
14+
"id": "e2ec5146",
15+
"metadata": {},
16+
"outputs": [],
17+
"source": [
18+
"num1 = 3\n",
19+
"num2 = -2\n",
20+
"\n",
21+
"for k in range(1, 10**6):\n",
22+
" x = num1 - k*num2\n",
23+
" if x < k:\n",
24+
" continue\n",
25+
" if x >=0 and bin(x).count('1') <= k:\n",
26+
" print(k)\n",
27+
"\n",
28+
"print(-1)"
29+
]
30+
}
31+
],
32+
"metadata": {
33+
"kernelspec": {
34+
"display_name": "Python 3",
35+
"language": "python",
36+
"name": "python3"
37+
},
38+
"language_info": {
39+
"codemirror_mode": {
40+
"name": "ipython",
41+
"version": 3
42+
},
43+
"file_extension": ".py",
44+
"mimetype": "text/x-python",
45+
"name": "python",
46+
"nbconvert_exporter": "python",
47+
"pygments_lexer": "ipython3",
48+
"version": "3.13.3"
49+
}
50+
},
51+
"nbformat": 4,
52+
"nbformat_minor": 5
53+
}

0 commit comments

Comments
 (0)