栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

zoj 3412 Special Special Judg...

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

zoj 3412 Special Special Judg...

#include <cstdio>#include <vector>using namespace std;const long long MOD = 1000000007LL;vector<int> p;long long gao(int n, int x, long long y) {if (n == 0) {return y/x;} else {return gao(n - 1, x, y) + gao(n - 1, x * -p[n - 1], y);}}long long gao(int x, long long y) {p.clear();for (int i = 2; i * i <= x; ++i) {if (x % i == 0) {p.push_back(i);while (x % i == 0) {x /= i;}}}if (x > 1) {p.push_back(x);}return gao(p.size(), 1, y);}int main() {int n, s, t, a;long long x, y;while (scanf("%d%d%d%lld%lld", &n, &s, &t, &x, &y) != EOF) {vector<long long> dp(t + 1, 0);dp[0] = 1LL;--x;for (int i = 0; i < n; ++i) {vector<long long> pre(t + 1, 0);vector<pair<int, long long> > cnt;pre.swap(dp);scanf("%d", &a);for (int b = 1; b * b <= a; ++b) {if (a % b == 0) {int c = a / b;cnt.push_back(make_pair(b, gao(c, y / b) - gao(c, x / b)));if (a / b > b) {cnt.push_back(make_pair(c, gao(b, y / c) - gao(b, x / c)));}}}for (int j = 0; j <= t; ++j) {for (int k = 0; k < (int)cnt.size(); ++k) {if (j + cnt[k].first <= t) {dp[j + cnt[k].first] = (dp[j + cnt[k].first] + pre[j] * cnt[k].second) % MOD;}}}}long long ans = 0;for (int j = s; j <= t; ++j) {ans += dp[j];}printf("%lldn", ans % MOD);}return 0;}
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/372946.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号