CodeForces 111B - Petya and Divisors 统计..想法题
2013-07-25 18:09
316 查看
找每个数的约数(暴力就够了...1~x^0.5)....看这约数的倍数最后是哪个数...若距离大于了y..统计++...然后将这个约数的最后倍数赋值为当前位置...好叼的想法题....
Program:
Program:
#include<iostream> #include<stack> #include<queue> #include<stdio.h> #include<algorithm> #include<string.h> #include<cmath> #define ll long long #define oo 1000000007 #define MAXN 100005 using namespace std; int last[MAXN]; int main() { int T,t; scanf("%d",&T); memset(last,-1,sizeof(last)); for (t=1;t<=T;t++) { int x,y,ans,i,p; ans=0; scanf("%d%d",&x,&y); for (i=1;i*i<=x;i++) if (x%i==0) { if (t-last[i]>y) ans++; if (x-i*i && t-last[x/i]>y) ans++; last[i]=last[x/i]=t; } printf("%d\n",ans); } return 0; }
相关文章推荐
- CodeForces 111B - Petya and Divisors 统计..想法题
- codeforces 111B B. Petya and Divisors(数论)
- CF 111B Petya and Divisors【想法题+二分(可省略)】
- CodeForces 111B - Petya and Divisors- 暴力-数学
- 【Codeforces】66A - Petya and Java(模拟)
- 【codeforces】- Petya and Java(给不同的数,判断大小,选择不同数据类型)
- CodeForces 362B Petya and Staircases
- Codeforces_414C:Mashmokh_and_Reverse_Operation(想法题)
- 【CodeForces】66B - Petya and Countryside(递增子串变形题,模拟)
- Codeforces 112A-Petya and Strings(实现)
- 【CodeForces 577C】Vasya and Petya’s Game
- CodeForces 832 B. Petya and Exam
- Codeforces 112B-Petya and Square(实现)
- CodeForces 576A - Vasya and Petya's Game
- CodeForces 832B Petya and Exam
- Codeforces 362 E Petya and Pipes【费用流】好题
- Codeforces 112B-Petya and Square(实现)
- 【打CF,学算法——二星级】Codeforces 703B Mishka and trip (统计)
- [Codeforces] Round #425 Div.2 B. Petya and Exam
- CodeForces 832B Petya and Exam