Dream_Chaser队训练赛第一场 I题
Dream_Chaser队训练赛第一场 I题
题目来自2012成都区域赛
Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u
Description
This site contains relics of a village where civilization once flourished. One night, examining a writing record, you find some text meaningful to you. It reads as follows.
“Our village is of glory and harmony. Our relationships are constructed in such a way that everyone except the village headman has exactly one direct boss and nobody will be the boss of himself, the boss of boss of himself, etc. Everyone expect the headman is considered as his boss’s subordinate. We call it relationship configuration. The village headman is at level 0, his subordinates are at level 1, and his subordinates’ subordinates are at level 2, etc. Our relationship configuration is harmonious because all people at same level have the same number of subordinates. Therefore our relationship is …”
The record ends here. Prof. Tigris now wonder how many different harmonious relationship configurations can exist. He only cares about the holistic shape of configuration, so two configurations are considered identical if and only if there’s a bijection of n people that transforms one configuration into another one.
Please see the illustrations below for explanation when n = 2 and n = 4.
The result might be very large, so you should take module operation with modules 10 9 +7 before print your answer.
Input
For each test case there is a single line containing only one integer n (1 ≤ n ≤ 1000).
Input is terminated by EOF.
Output
Sample Input
Sample Output
1 #include<iostream> 2 #include<cstdio> 3 #include<cstdlib> 4 #include<cstring> 5 #include<algorithm> 6 #include<vector> 7 #include<stack> 8 #include<queue> 9 #include<map> 10 #include<set> 11 #include<math.h> 12 #include<string> 13 #include<cctype> 14 15 using namespace std; 16 17 const int maxn=1000100; 18 const int INF=(1<<29); 19 const double EPS=0.00000001; 20 typedef long long ll; 21 const ll p=1000000000+7; 22 23 ll n; 24 ll F[maxn]; 25 26 ll f(ll n) 27 { 28 if(F[n]!=-1) return F[n]; 29 if(n==1) return F[n]=1; 30 if(n==2) return F[n]=1; 31 if(n==3) return F[n]=2; 32 //return f(n-1)+(n%2==1?1:0)+1; 33 ll res=0; 34 res=(res%p+f(n-1)%p+1)%p; 35 for(int i=2;i<=n/2;i++){ 36 if(n%i==1) res=(res%p+f(n/i)%p)%p; 37 } 38 return F[n]=res%p; 39 } 40 41 void play() 42 { 43 for(int i=1;i<=1010;i++){ 44 printf("%I64d,",f(i)); 45 if(i%7==0) printf("\n"); 46 } 47 } 48 49 int main() 50 { 51 memset(F,-1,sizeof(F)); 52 int tag=1; 53 while(cin>>n){ 54 printf("Case %d: %I64d\n",tag++,f(n)); 55 } 56 return 0; 57 }
View Code
转载于:https://www.cnblogs.com/--560/p/4543047.html
Dream_Chaser队训练赛第一场 I题相关推荐
- Dream_Chaser队训练赛第一场 K题
Dream_Chaser队训练赛第一场 K题 题目来自2012成都区域赛 K - Yet Another Multiple Problem Time Limit:20000MS Memory ...
- 2021年度训练联盟热身训练赛第一场 H题On Average They‘re Purple(BFS)
题意: 给你一些联通关系,问Bob先选择一些路径(1~n)联通,Alice在路径上染色,Bob的目的是选择一些路径使得染色变化最小,对于Alice来说,需要使得在Bob选择的(1−n1-n1−n)d的 ...
- 2021年度热身训练赛第一场
2021年度热身训练赛第一场 A.Weird Flecks, But OK 题意 给定n个点以及n个点的三维坐标,用一根长度不限的圆柱以垂直x-y平面,x-z平面或y-z平面方式穿过所有点,求圆柱的最 ...
- HDU6578 2019HDU多校训练赛第一场 1001 (dp)
HDU6578 2019HDU多校训练赛第一场 1001 (dp) 传送门:http://acm.hdu.edu.cn/showproblem.php?pid=6578 题意: 你有n个空需要去填,有 ...
- 突击蓝桥杯嵌入式(十二)——第十二届省赛第一场真题 停车场
突击蓝桥杯嵌入式(十二)--第十二届省赛第一场真题 停车场 一.题干 二.题目解析 所需: PA7 PWM LED(锁存器) 串口9600 LCD 按键4个,整体难在逻辑,我们先配置好硬件,进入工程 ...
- 突击蓝桥杯嵌入式(七)——第十三届省赛第一场真题
突击蓝桥杯嵌入式(七)--第十三届省赛第一场真题 一.题目概览 二.思路梳理 我们直接在LCD例程的基础上,改需增加的外设如下: LED灯(配置锁存器PD2),串口(波特率9600,带中断),按键4个 ...
- 备战省赛组队训练赛第一场
目录 问题 A: 篮球队选拔 问题 B: 黑暗意志 问题 C: 调酒壶里的酸奶 问题 D: 过分的谜题 问题 E: 不存在的泳池 问题 F: fps游戏 问题 G: 流连人间的苏苏 问题 H: 路哥从 ...
- HDU 2019 Multi-University Training Contest 1 杭电2019多校联合训练赛 第一场 1001 Blank (6578)
HDU 2019 Multi-University Training Contest 1 杭电2019暑期多校集训第一场 1001 Blank (6578) Problem Description T ...
- 中国石油大学 2018-2019赛季多校联合新生训练赛第一场 题解与补题
这场比赛是在18年12月,因为当时完全不敢用C++,感觉很遥远的样子-代码都是拿C实现的,许多地方其实也可以优化的. 问题 A: 录取分数线 时间限制: 1 Sec 内存限制: 128 MB 题目描述 ...
最新文章
- 转	vi 编辑器,gcc 编译器的使用
- $_SERVER['SCRIPT_FILENAME'] 与 __FILE__ 区别
- jenkins搭建流程
- 合并两个有序链表,合并后依然有序(C语言)
- mysql8.0版本的服务器名称_Linux服务器配置-VSFTP服务配置(六)
- 【产品对比】Word开发工具Aspose.Words和Spire.Doc性能和优劣对比一览
- python 生成器对象_Python 生成器, 迭代器, 可迭代对象的区别
- 16kb等于多少b_面试官:MySQL索引为何选择B+树?
- 硬盘镜像和软盘镜像中内容的查看方法
- jade6.5安装教程
- TeamTalk HttpClient详解
- 索爱S318小蜜蜂扩音器性能如何?
- webpack随笔06-bulma
- 台式计算机把光驱改成硬盘,笔记本电脑光驱怎么改换硬盘?笔记本光驱改装固态硬盘图文教程...
- Android studio真机调试返回 Entry name ‘assets/ae/res.ck‘ collided
- java计算机毕业设计特色农产品供需销售系统源码+数据库+系统+lw文档+mybatis+运行部署
- mybatis 配置多数据源 java,SpringBoot+MyBatisPlus配置多数据源读写分离
- 【iOS】网络操作与AFNetworking
- 启动zkCli.sh时指定IP地址
- 基于改进人工蜂群算法的K均值聚类算法(Matlab代码实现)