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. Recurrent Neural Network(3):LSTM Basics and 《Inside Out》

    下图是Naive RNN的Recurrent Unit示意图,可以看到,在每个时间点t,Recurrent Unit会输出一个隐藏状态ht,对ht加工提取后将产生t时刻的输出yt.而在下一个时间节点t ...

  2. StringBuilder -字符串缓冲区,节约内层空间变长数组

    package cn.learn; /* 字符串缓冲区 -缓冲可提高效率 java.lang.StringBuilder 字符串的底层是一个被final修饰的数组,不能改变,是一个常量 private ...

  3. knn 数据集准备

    """ Created on Mon Aug 26 20:57:24 2019 @author: huoqs knn algorithm ""&quo ...

  4. Spring切面编程之AOP

    AOP 是OOP 的延续,是Aspect Oriented Programming 的缩写,意思是面向切面编程.可以通过预编译方式和运行期动态代理实现在不修改源代码的情况下给程序动态统一添加功能的一种 ...

  5. [已解决]报错: Error response from daemon: conflict

    报错内容: Error response from daemon: conflict: unable to delete f5b6ef70d79b (must be forced) - image i ...

  6. 线段树(two value)与树状数组(RMQ算法st表)

    士兵杀敌(三) 时间限制:2000 ms  |  内存限制:65535 KB 难度:5 描述 南将军统率着N个士兵,士兵分别编号为1~N,南将军经常爱拿某一段编号内杀敌数最高的人与杀敌数最低的人进行比 ...

  7. 21、numpy—Matplotlib

    NumPy Matplotlib Matplotlib 是 Python 的绘图库. 它可与 NumPy 一起使用,提供了一种有效的 MatLab 开源替代方案. 它也可以和图形工具包一起使用,如 P ...

  8. rsync之expect脚本shell

    r_expect.sh: #!/bin/expect -f set timeout 30 #spawn rsync -avz --delete --exclude-from=exclude.list ...

  9. 4.VUE前端框架学习记录四:Vue组件化编码2

    VUE前端框架学习记录四:Vue组件化编码2文字信息没办法描述清楚,主要看编码Demo里面,有附带完整的代码下载地址,有需要的同学到脑图里面自取.脑图地址http://naotu.baidu.com/ ...

  10. Sass函数:unit()函数

    unit() 函数主要是用来获取一个值所使用的单位,碰到复杂的计算时,其能根据运算得到一个“多单位组合”的值,不过只充许乘.除运算: >> unit(100) "" & ...