Ural 1091 Tmutarakan Exams
Tmutarakan Exams
This problem will be judged on Ural. Original ID: 1091
64-bit integer IO format: %lld Java class name: (Any)
Input
Output
Sample Input
3 10
Sample Output
11
Source
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = ;
LL c[maxn][maxn];
int p[] = {,,,,,,,,,};
void init() {
c[][] = ;
for(int i = ; i < maxn; ++i) {
c[i][] = c[i][i] = ;
for(int j = ; j < i; ++j)
c[i][j] = c[i-][j] + c[i-][j-];
}
}
int main() {
init();
int k,s;
while(~scanf("%d%d",&k,&s)) {
LL ret = ;
for(int i = ; i < ; ++i) {
if(s/p[i] < k) {
for(int j = ; j < (<<i); ++j) {
int cnt = ;
LL tmp = ;
for(int t = ; t < i; ++t) {
if((j>>t)&) {
cnt++;
tmp *= p[t];
}
}
if(cnt&) ret += c[s/tmp][k];
else ret -= c[s/tmp][k];
}
break;
}
}
printf("%I64d\n",ret > ?:ret);
}
return ;
}
Ural 1091 Tmutarakan Exams的更多相关文章
- ural 1091. Tmutarakan Exams(容斥原理)
1091. Tmutarakan Exams Time limit: 1.0 secondMemory limit: 64 MB University of New Tmutarakan trains ...
- ural 1091. Tmutarakan Exams 和 codeforces 295 B. Greg and Graph
ural 1091 题目链接:http://acm.timus.ru/problem.aspx?space=1&num=1091 题意是从1到n的集合里选出k个数,使得这些数满足gcd大于1 ...
- ural 1091. Tmutarakan Exams(容斥)
http://acm.timus.ru/problem.aspx? space=1&num=1091 从1~s中选出k个数,使得k个数的最大公约数大于1,问这种取法有多少种. (2<=k ...
- URAL - 1091 Tmutarakan Exams (简单容斥原理)
题意:K个不同数组成的集合,每个数都不超过S且它们的gcd>1.求这样的数的个数 分析:从2开始枚举gcd,但这样会发生重复.譬如,枚举gcd=2的集合个数和gcd=3的集合个数,枚举6的时候就 ...
- 1091. Tmutarakan Exams
1091. Tmutarakan Exams Time limit: 1.0 secondMemory limit: 64 MB University of New Tmutarakan trains ...
- 容斥原理--计算并集的元素个数 URAL 1091
在计数时,必须注意没有重复,没有遗漏.为了使重叠部分不被重复计算,人们研究出一种新的计数方法,这种方法的基本思想是:先不考虑重叠的情况,把包含于某内容中的所有对象的数目先计算出来,然后再把计数时重复计 ...
- F - Tmutarakan Exams URAL - 1091 -莫比乌斯函数-容斥 or DP计数
F - Tmutarakan Exams 题意 : 从 < = S 的 数 中 选 出 K 个 不 同 的 数 并 且 gcd > 1 .求方案数. 思路 :记 录 一 下 每 个 数 的 ...
- 2014 Super Training #3 H Tmutarakan Exams --容斥原理
原题: URAL 1091 http://acm.timus.ru/problem.aspx?space=1&num=1091 题意:要求找出K个不同的数字使他们有一个大于1的公约数,且所有 ...
- Tmutarakan Exams URAL - 1091(莫比乌斯函数 || 容斥)
题意: 求1 - s 中 找出k个数 使它们的gcd > 1 求这样的k个数的对数 解析: 从每个素数的倍数中取k个数 求方案数 然后素数组合,容斥一下重的 奇加偶减 莫比乌斯函数的直接套模 ...
随机推荐
- bzoj 1620: [Usaco2008 Nov]Time Management 时间管理【贪心】
按s从大到小排序,逆推时间模拟工作 #include<iostream> #include<cstdio> #include<algorithm> using na ...
- 最近我总结的常用mate标签-常用mate标签
昨天开始上班 ,今天晚上不是太忙 ,来写篇博客了 meta元素共有三个可选属性(http-equiv.name和scheme)和一个必选属性(content),content定义与 http-equ ...
- 基于ASP.Net Core开发一套通用后台框架记录-(数据库设计(权限模块))
写在前面 本系列博客是本人在学习的过程中搭建学习的记录,如果对你有所帮助那再好不过.如果您有发现错误,请告知我,我会第一时间修改. 前期我不会公开源码,我想是一点点敲代码,不然复制.粘贴那就没意思了. ...
- CentOS6.5磁盘分区和挂载操作记录
CentOS6.5磁盘分区和挂载操作记录. [root@CentOS ~]# fdisk -l Disk /dev/sda: bytes heads, sectors/track, cylinders ...
- Git学习笔记(0)-错误汇总
一.LF will be replaced by CRLF 1.发现问题 $ git add welcome.txt warning: LF will be replaced by CRLF in w ...
- A8ERP配送管理系统
- Scala-基础-函数(1)
import junit.framework.TestCase //函数(1) class Demo5 extends TestCase { def testDemo(){ println(" ...
- js中时钟表盘
1.js时钟表盘 代码 <!DOCTYPE html> <html lang="en"> <head> <meta charset=&qu ...
- js中获取class封装
1.封装 //封装getClass function getClass(tagName,className) //获得标签名为tagName,类名className的元素 { if(document. ...
- 【转】非常好的Java反射例子
转自 http://www.douban.com/note/306848299/ 原文: 1.Java反射的概念 反射含义:可以获取正在运行的Java对象. 2.Java反射的功能 1)可以判断运行时 ...