luogu P1869 愚蠢的组合数(质因数+瞎搞)
2024-10-20 20:51:54
题意
n<=105
题解
一个数是不是偶数就是看有没有二这个质因子。
所以我们先预处理每个数的阶乘的二这个质因子的数量
然后按公式判断就行了。
#include<iostream>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<algorithm>
using namespace std;
int t,a,b,cnt[];
int main(){
scanf("%d",&t);
for(int i=;i<=;i++){
int j=i;cnt[i]=cnt[i-];
while(j%==&&j){
j/=;cnt[i]++;
}
}
while(t--){
scanf("%d%d",&a,&b);
if(cnt[b]+cnt[a-b]==cnt[a])printf("1\n");
else printf("0\n");
}
return ;
}
最新文章
- SQL指南-SELECT语句
- SQL笔记-第七章,表连接
- php 使用zendstudio 生成webservice文件 wsdl
- Ogre1.8地形和天空盒的建立(一块地形)
- AD7190学习笔记
- BZOJ 3223 文艺平衡树 [codevs3303翻转区间]
- 在MVVMLight框架的ViewModel中实现NavigationService
- ubuntu下tcpdump使用
- 【转】20个令人敬畏的jQuery插件
- STL容器总结
- [转]Publishing and Running ASP.NET Core Applications with IIS
- 第二章:在HTML中使用JavaScript
- Regular Expression Syntax
- Java实现发送邮件(可配置)忘记密码,发送邮件
- 基于YOLOv3和Qt5的车辆行人检测(C++版本)
- ext图片预览功能实现,前端代码
- 安卓网络访问(xUtils3)
- Linux 内核里的“智能指针”【转】
- Centos7限速和测速
- hdu2886 Lou 1 Zhuang 数学/快速幂