HDU-4475 Downward paths(找规律)
Downward paths
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 844 Accepted Submission(s): 282
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.
For each test case, there is only one integer N (1 <= N <= 10^18) indicates the size of the graph.
Because the answer may be very large, you should just output the remainder of it divided by 1000003.
1
2
8
For Sample 2, the yellow paths in Figure 2 show the 8 downward paths.
********************************************************************************************
#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(找规律)的更多相关文章
- HDU 4861 Couple doubi(找规律|费马定理)
Couple doubi Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit ...
- hdu 2604 Queuing dp找规律 然后矩阵快速幂。坑!!
http://acm.hdu.edu.cn/showproblem.php?pid=2604 这题居然O(9 * L)的dp过不了,TLE, 更重要的是找出规律后,O(n)递推也过不了,TLE,一定 ...
- hdu 3951 - Coin Game(找规律)
这道题是有规律的博弈题目,,, 所以我们只需要找出规律来就ok了 牛人用sg函数暴力找规律,菜鸟手工模拟以求规律...[牢骚] if(m>=2) { if(n<=m) {first第一口就 ...
- HDU 5703 Desert (找规律)
题意:一杯水有n的容量,问有多少种方法可以喝完. 析:找规律,找出前几个就发现规律了,就是2的多少次幂. 代码如下: #include <cstdio> #include <stri ...
- hdu 4952 Number Transformation (找规律)
题目链接 题意:给你个x,k次操作,对于第i次操作是:要找个nx,使得nx是>=x的最小值,且能整除i,求k次操作后的数 分析: 经过打表找规律,会发现最后的x/i,这个倍数会趋于一个固定的值, ...
- hdu 5241 Friends(找规律?)
Friends Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Total S ...
- HDU 4279 Number(找规律)
Number Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Sub ...
- hdu 1021 Fibonacci Again(找规律)
http://acm.hdu.edu.cn/showproblem.php?pid=1021 Fibonacci Again Time Limit: 2000/1000 MS (Java/Others ...
- HDU 5963 朋友(找规律博弈)
http://acm.hdu.edu.cn/showproblem.php?pid=5963 题意: 思路: 我们可以先只考虑单链,自己试几种案例就可以发现规律,只有与根相连的边为1时,只需要奇数次操 ...
- HDU 5963 朋友 (找规律,思维)
HDU 5963 朋友 题目大意 B君在围观一群男生和一群女生玩游戏,具体来说游戏是这样的: 给出一棵n个节点的树,这棵树的每条边有一个权值,这个权值只可能是0或1. 在一局游戏开始时,会确定一个节点 ...
随机推荐
- 【SD系列】SAP 跨年时更改销售凭证号码段
公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[SD系列]SAP 跨年时更改销售凭证号码段 ...
- 编程语言-Python2-问题整理
InsecureRequestWarning: Unverified HTTPS request is being made. import urllib3 urllib3.disable_warni ...
- [Codeforces 639F] Bear and Chemistry (Tarjan+虚树)(有详细注释)
[Codeforces 639F] Bear and Chemistry(Tarjan+虚树) 题面 给出一个n个点,m条边的无向图(不保证连通,可能有自环和重边),有q次询问,每次询问给出p个点和q ...
- Codeforces 1105C (DP)
题面 传送门 分析 这种计数问题,要不是纯数学推公式,要不就是dp 先处理出[l,r]中除3余0,1,2的数的个数,记为cnt0,cnt1,cnt2 设\(dp[i][j]\)表示前i个数的和除3余j ...
- P2579 [ZJOI2005]沼泽鳄鱼(矩乘)
P2579 [ZJOI2005]沼泽鳄鱼 没有食人鱼:直接矩乘优化 有食人鱼:食人鱼周期2.3.4,公倍数12,可以以12为一个周期矩乘,剩下的暴力 注意矩乘不满足乘法交换律,一定要注意乘的顺序 #i ...
- 消息中间件-技术专区-RocketMQ架构原理
RocketMQ是阿里开源的分布式消息中间件,跟其它中间件相比,RocketMQ的特点是纯JAVA实现:集群和HA实现相对简单:在发生宕机和其它故障时消息丢失率更低. 一.RocketMQ专业术语 P ...
- 快速部署业务类为webapi服务
接着前一篇博文,将接口快速打包固定请求格式,不需要修改代码,可以自动完成接口调用,实际上就是生成了一个接口的代理类. 那么仅仅是接口请求代理,没有服务端怎么行?所以需要将实现接口的类部署为webapi ...
- 根据select选择来控div是否显示,默认这个div是隐藏的,
<!DOCTYPE html><html><head lang="cn"><title>Insert title here</ ...
- vue,一路走来(16)--本地及手机调试
闲暇时间记录一下如何绑定域名,实现本地及手机调试的过程.我的是微信开发项目,很多功能及操作都是基于微信来开发的,理所当然的就用到微信开发者工具了. 1.首先打开目录C:\Windows\System3 ...
- vue,一路走来(15)--简单投票系统
今天记录一下简单的投票系统,主要实现选中至少五张作品,并提交投票. 思路:选中作品,将作品id存入到数组里. 取消投票,则从数组中移除该作品id. 如图效果: <li v-for="( ...