Hdu 2841
来源:互联网 发布:电脑运行网络命令大全 编辑:程序博客网 时间:2024/05/28 06:04
题目链接:
http://acm.hdu.edu.cn/showproblem.php?pid=2841
题目大意:
在平面
分析:
如果一棵树的坐标为
那么只要枚举所有满足坐标
代码:
#include <cstdio>#include <cstring>#include <algorithm>using namespace std;typedef long long ll;const ll mod = 1e9+7;const int maxn = 100000+10;vector<int> ft[120005];bool isprime[120000];void init(){ for (int i = 2 ; i <= maxn ; i ++) { if (!isprime[i]) { for (int j = i ; j <= maxn ; j += i) { isprime[j] = true; ft[j].push_back(i); } } }}ll solve(int x,int sta,ll n){ int pos = 0; ll temp = 1; while (sta) { if (sta&1) temp *= ft[x][pos]; pos ++; sta >>= 1; } return n/temp;}int m,n;int main(){ init(); int T,t=1; scanf("%d",&T); while (T--) { scanf("%d%d",&m,&n); if (m>n) swap(m,n); ll ans = 0; for (int i = 1 ; i <= n ; i ++) { ans += m; for (int j = 1 ; j < (1<<ft[i].size()); j ++) { ll temp = solve(i,j,m);int cp = j,cnt = 0; //printf("cp = %n\t",cp); while (cp) { cp -= cp&(-cp); cnt++; } //printf("cnt = %n\n",cnt); if (cnt&1) ans -= temp; else ans += temp; } //printf("%d\n",ans); } printf("%lld\n",ans); } return 0;}
阅读全文
0 0
- hdu 2841
- Hdu 2841
- hdu 1695 hdu 2841 容斥原理
- HDU 2841 Visible Trees
- HDU 2841 Visible Trees
- HDU 2841 Visible Trees
- hdu 2841 Visible Trees
- hdu
- hdu
- HDU
- hdu ()
- hdu
- hdu
- HDU
- HDU
- hdu
- hdu
- HDU
- 析构函数(destructor)
- 数据对象
- python 获取指定文件夹下所有文件名称并写入列表
- 二、hibernate一对多关联
- halcon始终显示十字叉
- Hdu 2841
- zabbix客户端端部署 for CentOS7
- 删
- xml school
- easyuidatagrid中load,reload,loadData的区别。
- 权限管理框架Shiro学习
- Exercise: Maps
- MATLAB做曲线拟合
- SpringBoot 入门