大意: 给定A,B,C, 求有多少个三元组$(a,b,c)$, 满足$a \le b \le c$, 且以若干个$(a,b,c)$为三边的长方体能填满边长(A,B,C)的长方体.

暴力枚举出$A,B,C$的所有整除关系的数量, 这样可以避免重复计数, 最后再用可重组合统计一下结果

#include <iostream>
#include <algorithm>
#include <math.h>
#include <cstdio>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <string.h>
#include <queue>
#define PER(i,a,n) for(int i=n;i>=a;--i)
#define REP(i,a,n) for(int i=a;i<=n;++i)
#define hr cout<<'\n'
#define pb push_back
#define mid ((l+r)>>1)
#define lc (o<<1)
#define rc (lc|1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false);
#define endl '\n'
using namespace std;
typedef unsigned long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
void exgcd(ll a,ll b,ll &d,ll &x,ll &y){b?exgcd(b,a%b,d,y,x),y-=a/b*x:x=1,y=0,d=a;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
//head

const int N = 1e5+10, S = 7;
int c[10], f[N];

ll C(int n, int m) {
	ll r = 1;
	REP(i,1,m) r*=n,--n;
	REP(i,1,m) r/=i;
	return r;
}

int check(int a,int b,int c) {

    if((a&1)&&(b&2)&&(c&4))
        return true;
    if((a&1)&&(c&2)&&(b&4))
        return true;
    if((b&1)&&(a&2)&&(c&4))
        return true;
    if((b&1)&&(c&2)&&(a&4))
        return true;
    if((c&1)&&(a&2)&&(b&4))
        return true;
    if((c&1)&&(b&2)&&(a&4))
        return true;
    return false;
}

void work() {
	int x, y, z;
	scanf("%d%d%d", &x, &y, &z);
	int xy=gcd(x,y),yz=gcd(y,z),xz=gcd(z,x),xyz=gcd(z,xy);
	c[7]=f[xyz];
	c[6]=f[xy]-c[7];
	c[5]=f[xz]-c[7];
	c[3]=f[yz]-c[7];
	c[4]=f[x]-c[5]-c[6]-c[7];
	c[2]=f[y]-c[6]-c[3]-c[7];
	c[1]=f[z]-c[5]-c[3]-c[7];
	ll ans = 0;
	REP(i,0,7)REP(j,i,7)REP(k,j,7) if (check(i,j,k)) {
		int u[10]={};
		++u[i],++u[j],++u[k];
		ll t = 1;
		REP(i,1,7) if (u[i]) t*=C(c[i]+u[i]-1,u[i]);
		ans += t;
	}
	printf("%llu\n", ans);
}

int main() {
	REP(i,1,N-1) for (int j=i; j<N; j+=i) ++f[j];
	int t;
	scanf("%d", &t);
	while (t--) work();
}

Pave the Parallelepiped CodeForces - 1007B (计数)的更多相关文章

  1. codeforces 1007B Pave the Parallelepiped

    codeforces 1007B Pave the Parallelepiped 题意 题解 代码 #include<bits/stdc++.h> using namespace std; ...

  2. CF1007B Pave the Parallelepiped 容斥原理

    Pave the Parallelepiped time limit per test 2 seconds memory limit per test 256 megabytes input stan ...

  3. [CF1007B]Pave the Parallelepiped[组合计数+状态压缩]

    题意 \(t\) 组询问,给你 \(A, B, C\) ,问有多少组三元组 \((a, b, c)\) 满足他们任意排列后有: \(a|A,\ b|B,\ c|C\) . \(A,B,C,t\leq ...

  4. CodeForces 558E(计数排序+线段树优化)

    题意:一个长度为n的字符串(只包含26个小字母)有q次操作 对于每次操作 给一个区间 和k k为1把该区间的字符不降序排序 k为0把该区间的字符不升序排序 求q次操作后所得字符串 思路: 该题数据规模 ...

  5. Codeforces 1065E(计数)

    题目链接 题意 限定字符串长度为$n$,字符集规模为$A$,以及$m$个数字$b$,对于任意数字$bi$满足长度为$bi$的前缀和后缀先反转再交换位置后形成的新串与原串视作相等,问存在多少不同串. 思 ...

  6. Bug in Code CodeForces - 420C (计数,图论)

    大意: 给定$n$结点无向图, 共n条边, 有重边无自环, 求有多少点对(u,v), 满足经过u和v的边数>=p 可以用双指针先求出所有$deg_u+deg_v \ge p$的点对, 但这样会多 ...

  7. A Creative Cutout CodeForces - 933D (计数)

    大意:给定$n$个圆, 圆心均在原点, 第$k$个圆半径为$\sqrt{k}$ 定义一个点的美丽值为所有包含这个点的圆的编号和 定义函数$f(n)$为只有$n$个圆时所有点的贡献,求$\sum_{k= ...

  8. codeforces 466C 计数 codeforces 483B 二分 容斥

    题意:给你n个数,将他们分成连续的三个部分使得每个部分的和相同,求出分法的种数. 思路:用一个数组a[i]记下从第一个点到当前i点的总和.最后一个点是总和为sum的点,只需求出总和为1/3sum的点和 ...

  9. Scalar Queries CodeForces - 1167F (计数,树状数组)

    You are given an array $a_1,a_2,…,a_n$. All $a_i$ are pairwise distinct. Let's define function $f(l, ...

随机推荐

  1. Fatal error in launcher: Unable to create process using '"c:\python37\python3.exe" "C:\Python37\Scripts\pip3.exe" install opencv-python'

    pip3.exe install opencv-python 报错: Fatal error in launcher: Unable to create process using '"c: ...

  2. 更快写入的落脚点不是线程数而是mysql连接数 对数据库 批处理 批写入

    批提交mysql 单线程的批提交 nohup  python fromRedisoToMysqlSingleThreadOneConnBatchInsert.py 100 10.24.192.192 ...

  3. ELK服务基础

    官方文档 什么是ELK? 通俗来讲,ELK是由Elasticsearch.Logstash.Kibana三个开源软件组成的一个组合体,这三个软件当中,每个软件用于完成不同的功能,ELK又称为ELK s ...

  4. mysql float 浮点型

    定点数类型 DEC等同于DECIMAL 浮点类型:FLOAT DOUBLE 作用:存储薪资.身高.体重.体质参数等 m,d 都是设置宽度 =============================== ...

  5. Android仿今日头条手界面

    public class MyIndicator extends HorizontalScrollView implements ViewPager.OnPageChangeListener { pr ...

  6. Linux中的Buffer Cache和Page Cache echo 3 > /proc/sys/vm/drop_caches Slab内存管理机制 SLUB内存管理机制

    Linux中的Buffer Cache和Page Cache echo 3 > /proc/sys/vm/drop_caches   Slab内存管理机制 SLUB内存管理机制 http://w ...

  7. Word 2010文档自动生成目录和某页插入页码

    一.Word 2010文档自动生成目录 关于Word文档自动生成目录一直是我身边同学们最为难的地方,尤其是毕业论文,经常因为目录问题,被要求修改,而且每次修改完正文后,目录的内容和页码可能都会发生变化 ...

  8. js-template-art【三】js api

    一.js api使用 1.template(filename, data) 根据模板名渲染模板. var html = template('tplScriptId', { value: 'aui' } ...

  9. 多图片生成pdf文件

    这里记录多个图片合并生成一个pdf文件的方法. 首先maven引入所需jar包: <dependency> <groupId>com.itextpdf</groupId& ...

  10. python学习笔记(二十八)日志模块

    我们在写程序的时候经常会打一些日志来帮助我们查找问题,这次学习一下logging模块,在python里面如何操作日志.介绍一下logging模块,logging模块就是python里面用来操作日志的模 ...