bzoj3505 [Cqoi2014]数三角形
来源:互联网 发布:红米note2手机壳淘宝 编辑:程序博客网 时间:2024/06/05 02:40
题目
先选3个点的总数减去三点共线的,横的,竖的,斜的,都一减就好了。
#include<bits/stdc++.h>#define N 1000using namespace std;int gcd[N+1][N+1];int m,n;long long tmp,ans;int read(){ int x=0; char c=getchar(); while(c>'9'||c<'0')c=getchar(); while(c<='9'&&c>='0')x=x*10+c-'0',c=getchar(); return x;}int GCD(int a,int b){ if(a<b)swap(a,b); if(gcd[a][b]!=-1)return gcd[a][b]; return gcd[a][b]= b==0?a:GCD(b,a%b); }int main(){ memset(gcd,-1,sizeof(gcd)); n=read(),m=read(); tmp=(long long)(n+1)*(m+1); ans=tmp*(tmp-1)*(tmp-2)/6; for(int i=0;i<=n;i++) { for(int j=0;j<=m;j++) if(i||j) { if(!i||!j)ans-=(long long)(GCD(i,j)-1)*(n-i+1)*(m-j+1); else ans-=(long long)2*(GCD(i,j)-1)*(n-i+1)*(m-j+1); } } cout<<ans; return 0;}
阅读全文
0 0
- [Bzoj3505][Cqoi2014]数三角形
- bzoj3505 [Cqoi2014]数三角形
- bzoj3505: [Cqoi2014]数三角形
- bzoj3505 [Cqoi2014]数三角形
- 【CQOI2014】【BZOJ3505】数三角形
- bzoj3505【CQOI2014】数三角形
- bzoj3505: [Cqoi2014]数三角形
- 【bzoj3505】[Cqoi2014]数三角形
- bzoj3505 [Cqoi2014]数三角形
- bzoj3505 [Cqoi2014]数三角形
- BZOJ3505 [Cqoi2014]数三角形
- 【bzoj3505】 CQOI2014数三角形 数学
- bzoj3505 [Cqoi2014]数三角形 题解
- BZOJ3505 [Cqoi2014]数三角形 数学
- 【bzoj3505】【CQOI2014】【数三角形】【组合数学】
- BZOJ3505: [Cqoi2014]数三角形 解题报告
- 组合数学+gcd BZOJ3505 [Cqoi2014]数三角形
- 【组合】BZOJ3505(Cqoi2014)[数三角形]题解
- (七)Working with System Permissions使用系统权限
- 如何在Listview中拖拽其中的子Item移动其位置
- bzoj2463 [中山市选2009]谁能赢呢?
- bzoj2761 [JLOI2011]不重复数字
- Mark 一些有意思的深度学习方向
- bzoj3505 [Cqoi2014]数三角形
- HDU1048 凯撒加密
- Permissions on the password database may be too restrictive.
- bzoj4300 绝世好题
- 运算
- #ZCH快捷键
- Win7(64位)系统下Python3.6.0(Anaconda3-4.4.0)+Tensorflow的安装与配置
- 设计模式总结一
- http请求的方法