Skip to content

Commit 9b79a7e

Browse files
committed
update
1 parent 3ef83af commit 9b79a7e

File tree

3 files changed

+96
-0
lines changed

3 files changed

+96
-0
lines changed
+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#include <cstdio>
2+
#include <cmath>
3+
#include <cstring>
4+
#include <string>
5+
#include <algorithm>
6+
#include <iostream>
7+
#include<queue>
8+
using namespace std;
9+
10+
int vis[100005];
11+
int main()
12+
{
13+
int i,j;
14+
int n;
15+
int x,y;
16+
cin>>n;
17+
memset(vis,-1,sizeof(vis));
18+
for (i=1;i<=n;i++)
19+
{
20+
int ans=0;
21+
scanf("%d%d",&x,&y);
22+
int len=sqrt((double)x);
23+
for (j=1;j<=len;j++)
24+
{
25+
if (x%j) continue;
26+
if (i-y>vis[j]) ans++;
27+
vis[j]=i;
28+
if (j*j==x) continue;
29+
if (i-y>vis[x/j]) ans++;
30+
vis[x/j]=i;
31+
}
32+
printf("%d\n",ans);
33+
}
34+
return 0;
35+
36+
}
37+
+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#include <cstdio>
2+
#include <cstring>
3+
#include <iostream>
4+
5+
using namespace std;
6+
7+
const int maxn = 15, lim = 1024;
8+
int has[maxn][maxn], n;
9+
10+
void fill(int r, int c, int lft) {
11+
if (r > n) return ;
12+
has[r][c] += lft;
13+
14+
if (has[r][c] > lim) {
15+
int left = has[r][c] - lim;
16+
has[r][c] = lim;
17+
fill(r + 1, c, left / 2);
18+
fill(r + 1, c + 1, left / 2);
19+
}
20+
}
21+
22+
int main()
23+
{
24+
int t;
25+
cin >> n >> t;
26+
memset(has, 0, sizeof(has));
27+
while(t--) {
28+
fill(1, 1, lim);
29+
}
30+
int ans = 0;
31+
for (int i = 1; i <= n; i++) {
32+
for (int j = 1; j <= i; j++) {
33+
ans += has[i][j] == lim;
34+
}
35+
}
36+
cout << ans << endl;
37+
return 0;
38+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#arr = [2,4,12,5,7,24,6,3]
2+
3+
4+
def fucSunlight(arr, i):
5+
global maxx, cntt
6+
if i >= len(arr):
7+
return
8+
if arr[i] > maxx:
9+
cntt+=1
10+
maxx = arr[i]
11+
fucSunlight(arr, i+1)
12+
13+
tCs = int(input())
14+
while(tCs):
15+
maxx = 0
16+
cntt = 0
17+
tCs -= 1
18+
sz = int(input())
19+
arr = list(map(int,input().split()))
20+
fucSunlight(arr,0)
21+
print(cntt)

0 commit comments

Comments
 (0)