Downward paths

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 844    Accepted Submission(s): 282

Problem Description
================

  Hi! I am an ACMer from CSU. This contest made by me is to celebrate my girlfriend’s birthday although the problems in this contest do not relate to her in fact. :) Any way, happy birthday to you, honey!

  Thanks to LCY, I have this chance to share my ideas and works with you. Good luck and have fun!
================
  We have a graph with size = N like that in Figure 1. Then we are going to find a downward path from the top node to one bottom node.
  First, we select the top node as the beginning. Then at any node, we can go horizontally or downward along the blue edge and reach the next node. The finding will be end when we reach one of the bottom nodes. After that we can get a downward path from the top node to one bottom node. Note that we can not pass a blue edge that we have passed ago during each finding.
  Your task is to calculate there exists how many downward paths.

 
Input
  There is an integer T (1 <= T <= 1000) in the first line, which indicates there are T test cases in total.
  For each test case, there is only one integer N (1 <= N <= 10^18) indicates the size of the graph.
 
Output
  For each test case, you should output the correct answer of the above task in one line.
  Because the answer may be very large, you should just output the remainder of it divided by 1000003.
 
Sample Input
2
1
2
 
Sample Output
2
8

Hint

  For Sample 2, the yellow paths in Figure 2 show the 8 downward paths.

 

********************************************************************************************

题意:从顶点走到底有多少条路可以走
解题思路:
    size = 1时:2*(1+0) = 2
size = 2时:2*(1+1) *2(1+0)= 8
size = 3时:2*(1+1)*2*(1+2)*2*(1+0)=48
除了最上面的顶点和最下面的点以外,size大于1时,
             1
            |    |
          2 ————3  
         |      |      |
        4————5————6
       |         |     |    |
      7————8————9————10
例如2号点可以有去4,5号点2条路,而且同时4, 5, 6这一层有2个边,4-5和5-6;
所以2号点到下一层就有2*(1+2)条路。
 
所以当size=n时,2 *(1+1)* 2 *(1+2)* 2 *(1+3) * ~~~ * 2 *(1+n-1)* 2 *(1+0)= 2^n * n!。
 
当大于1000003之后,全部n%1000003=0。
 
*********************************************************************************************
 #include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <sstream>
#include <algorithm>
using namespace std;
#define pb push_back
#define mp make_pair
#define mset(a, b) memset((a), (b), sizeof(a))
typedef long long LL;
const int inf = 0x3f3f3f3f;
const int maxn = +;
const int mod = ;
LL a[maxn];
int main()
{
a[] = ;
for(int i=;i<=maxn;i++)
a[i] = (a[i-] * i * )%mod;
LL T;
cin >> T;
while(T--){
LL n;
cin >> n;
if(n >= mod ){
cout << "" << endl;
continue;
}
cout << a[n] << endl;
}
return ;
}
 
 

HDU-4475 Downward paths(找规律)的更多相关文章

  1. HDU 4861 Couple doubi(找规律|费马定理)

    Couple doubi Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit ...

  2. hdu 2604 Queuing dp找规律 然后矩阵快速幂。坑!!

    http://acm.hdu.edu.cn/showproblem.php?pid=2604 这题居然O(9 * L)的dp过不了,TLE,  更重要的是找出规律后,O(n)递推也过不了,TLE,一定 ...

  3. hdu 3951 - Coin Game(找规律)

    这道题是有规律的博弈题目,,, 所以我们只需要找出规律来就ok了 牛人用sg函数暴力找规律,菜鸟手工模拟以求规律...[牢骚] if(m>=2) { if(n<=m) {first第一口就 ...

  4. HDU 5703 Desert (找规律)

    题意:一杯水有n的容量,问有多少种方法可以喝完. 析:找规律,找出前几个就发现规律了,就是2的多少次幂. 代码如下: #include <cstdio> #include <stri ...

  5. hdu 4952 Number Transformation (找规律)

    题目链接 题意:给你个x,k次操作,对于第i次操作是:要找个nx,使得nx是>=x的最小值,且能整除i,求k次操作后的数 分析: 经过打表找规律,会发现最后的x/i,这个倍数会趋于一个固定的值, ...

  6. hdu 5241 Friends(找规律?)

    Friends Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total S ...

  7. HDU 4279 Number(找规律)

    Number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Sub ...

  8. hdu 1021 Fibonacci Again(找规律)

    http://acm.hdu.edu.cn/showproblem.php?pid=1021 Fibonacci Again Time Limit: 2000/1000 MS (Java/Others ...

  9. HDU 5963 朋友(找规律博弈)

    http://acm.hdu.edu.cn/showproblem.php?pid=5963 题意: 思路: 我们可以先只考虑单链,自己试几种案例就可以发现规律,只有与根相连的边为1时,只需要奇数次操 ...

  10. HDU 5963 朋友 (找规律,思维)

    HDU 5963 朋友 题目大意 B君在围观一群男生和一群女生玩游戏,具体来说游戏是这样的: 给出一棵n个节点的树,这棵树的每条边有一个权值,这个权值只可能是0或1. 在一局游戏开始时,会确定一个节点 ...

随机推荐

  1. postman测试wsdl类型接口

    1 IP地址来源搜索 WEB 服务 接口信息 http://www.webxml.com.cn/WebServices/WeatherWebService.asmx?wsdl 2  设置接口调用地址 ...

  2. System.Web.Script.Serialization的引用

    解决方案: 找到C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0 ==>System.Web.Extensions.d ...

  3. C#后台获取当前时间并格式化

    最常用的:DateTime.Now.ToString("yyyy-MM-dd"); //今天DateTime.Now.Date.ToShortDateString(); //昨天, ...

  4. 排序算法三:堆排序(Heapsort)

    堆排序(Heapsort)是一种利用数据结构中的堆进行排序的算法,分为构建初始堆,减小堆的元素个数,调整堆共3步. (一)算法实现 protected void sort(int[] toSort) ...

  5. python中进程池和回调函数

    一.数据共享 1.进程间的通信应该尽量避免共享数据的方式 2.进程间的数据是独立的,可以借助队列或管道实现通信,二者都是基于消息传递的. 虽然进程间数据独立,但可以用过Manager实现数据共享,事实 ...

  6. nodejs启动

    npm install cnpm install npm run dev cnpm install 与 npm install :  https://blog.csdn.net/meng_suiga/ ...

  7. spring-第十一篇之SpEL表达式

    1.spring表达式语言,简称SpEL表达式语言

  8. spring-第四篇之让bean获取所在的spring容器

    1.如上一篇文章所述,有时候bean想发布一些容器事件,就需要先获取spring容器,然后将Event交由spring容器将事件发布出去. 为了让bean获取它所在的spring容器,可以让该bean ...

  9. bzoj1897. tank 坦克游戏(决策单调性分治)

    题目描述 有这样一款新的坦克游戏.在游戏中,你将操纵一辆坦克,在一个N×M的区域中完成一项任务.在此的区域中,将会有许多可攻击的目标,而你每摧毁这样的一个目标,就将获得与目标价值相等的分数.只有获得了 ...

  10. 图例演示在Linux上快速安装软RAID的详细步骤

    物理环境:虚拟机centos6.4 配置:8G内存.2*2核cpu.3块虚拟硬盘(sda,sdb,sdc,sdb和sdc是完全一样的)        在实际生产环境中,系统硬盘与数据库和应用是分开的, ...