题目链接:点击传送

INTSUB - Interesting Subset

no tags 

You are given a set X = {1, 2, 3, 4, … , 2n-1, 2n} where n is an integer. You have to find the number of interesting subsets of this set X.

A subset of set X is interesting if there are at least two integers a & b  such that b is a multiple of a, i.e. remainder of b divides by a is zero and a is the smallest number in the set.

Input

The input file contains multiple test cases. The first line of the input is an integer T(<=30) denoting the number of test cases. Each of the next T lines contains an integer 'n' where 1<=n<=1000.

Output

For each test case, you have to output as the format below:

Case X: Y

Here X is the test case number and Y is the number of subsets. As the number Y can be very large, you need to output the number modulo 1000000007.

Example

Input:
3
1
2
3

Output:
Case 1: 1
Case 2: 9
Case 3: 47

题意:给你2*n个数,你最小需要选两个,使得这个子集中含有最小值的倍数;

思路:枚举最小值,对于其倍数最小取一个,其余随意取与不取;

#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<queue>
#include<algorithm>
#include<stack>
#include<cstring>
#include<vector>
#include<list>
#include<set>
#include<map>
using namespace std;
#define ll long long
#define pi (4*atan(1.0))
#define eps 1e-14
#define bug(x) cout<<"bug"<<x<<endl;
const int N=1e5+,M=1e6+,inf=;
const ll INF=1e18+,mod=1e9+;
ll qpow(ll a,ll b,ll c)
{
ll ans=;
while(b)
{
if(b&)ans=(ans*a)%c;
b>>=;
a=(a*a)%c;
}
return ans;
}
int main()
{
int T,cas=;
scanf("%d",&T);
while(T--)
{
int n;
scanf("%d",&n);
ll ans=;
for(int i=;i<=n;i++)
{
int p=(*n-i);
int b=((*n)/i-);
ans=(ans+(qpow(,p-b,mod)*(qpow(,b,mod)+(mod-))%mod)%mod)%mod;
}
printf("Case %d: %lld\n",cas++,ans);
}
return ;
}

Interesting Subset

SPOJ - INTSUB

SPOJ - INTSUB 数学的更多相关文章

  1. SPOJ INTSUB - Interesting Subset(数学)

    http://www.spoj.com/problems/INTSUB/en/ 题意:给定一个集合,该集合由1,2,3....2n组成,n是一个整数.问该集合中有趣子集的数目,答案mod1e9+7. ...

  2. SPOJ FAVDICE 数学期望

    题目大意: 一个有n面的色子抛掷多少次能使所有面都能被抛到过,求期望值 总面数为n,当已经抛到过 i 个不同面时,我们抛出下一个不同面的概率为 (n-i)/n,那么抛的次数为 n/(n-i) 将所有抛 ...

  3. SPOJ:NPC2016A(数学)

    http://www.spoj.com/problems/NPC2016A/en/ 题意:在一个n*n的平面里面,初始在(x,y)需要碰到每条边一次,然后返回(x,y),问最短路径是多长. 思路:像样 ...

  4. SPOJ Favorite Dice(数学期望)

    BuggyD loves to carry his favorite die around. Perhaps you wonder why it's his favorite? Well, his d ...

  5. SPOJ:Robot(数学期望)

    There is a robot on the 2D plane. Robot initially standing on the position (0, 0). Robot can make a ...

  6. SPOJ:OR(位运算&数学期望)

    Given an array of N integers A1, A2, A3…AN. If you randomly choose two indexes i ,j such that 1 ≤ i ...

  7. SPOJ SUMPRO(数学)

    题意: 给出一个数N,问所有满足n/x=y(此处为整除)的所有x*y的总和是多少.对答案mod(1e9+7). 1 <= T <= 500. 1 <= N <= 1e9. 分析 ...

  8. 杜教筛进阶+洲阁筛讲解+SPOJ divcnt3

    Part 1:杜教筛进阶在了解了杜教筛基本应用,如$\sum_{i=1}^n\varphi(i)$的求法后,我们看一些杜教筛较难的应用.求$\sum_{i=1}^n\varphi(i)*i$考虑把它与 ...

  9. SPOJ 74. Divisor Summation 分解数字的因子

    本题有两个难点: 1 大量的数据输入.没处理好就超时 - 这里使用buffer解决 2 因子分解的算法 a)暴力法超时 b)使用sieve(筛子),只是当中的算法逻辑也挺不easy搞对的. 数值N因子 ...

随机推荐

  1. [LeetCode] 58. Length of Last Word_Easy tag: String

    Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the l ...

  2. CentOS.56安装Redis监控工具RedisLive

    RedisLive是一款开源的基于WEB的reids的监控工具,以WEB的形式展现出redis中的key的情况,实例数据等信息! RedisLive在github上的地址:https://github ...

  3. [lr] 直方图

    直方图基础知识 • 直方图的特征和作用 ▪ 直方图的x轴从左到右代表亮度逐渐增加,即从最暗到最亮:y轴代表某个亮度值下颜色像素的多少(密度). ▪ 直方图由红绿蓝三种颜色组成,分别表示红绿蓝通道:其中 ...

  4. css 播放器按钮实现

    效果图 html代码 //播放按钮 <div id="playBtn" class="circle" style="margin: 20px 0 ...

  5. cmd 笔记(随时补充)

    被一篇破解WIFI的标题文骗到了,所以学习一下CMD的命令 1 查看已经连接的wifi和密码 netsh wlan show profiles 回车 netsh wlan show profiles ...

  6. java常用功能

    1.复制文件 private void fileChannelCopy(File source, File target) throws IOException { FileInputStream f ...

  7. HZNU_TI1050 训练实录

    菜鸡队训练实录 比赛记录:[名称:奖项 / 排名] 2018: ZJPSC                       Bronze      / 86 CCPC Jilin              ...

  8. java opencv使用相关

    Using OpenCV Java with Eclipse http://docs.opencv.org/2.4/doc/tutorials/introduction/java_eclipse/ja ...

  9. linux常用命令:ss 命令

    ss是Socket Statistics的缩写.顾名思义,ss命令可以用来获取socket统计信息,它可以显示和netstat类似的内容.但ss的优势在于它能够显示更多更详细的有关TCP和连接状态的信 ...

  10. web前端----css选择器样式

    一.css概述 CSS是Cascading Style Sheets的简称,中文称为层叠样式表,对html标签的渲染和布局 CSS 规则由两个主要的部分构成:选择器,以及一条或多条声明. 例如 二.c ...