UVA12653 Buses
Problem H
Buses
File: buses.[c|cpp|java]
Programming competitions usually require infrastructure and organization on the part of those
responsible. A problem that frequently must be solved is regarding transportation. While participating
in a recent competition, Ricardinho watched the buses and micro-buses used in the transportation of
competitors, all lined up one behind the other as competitors disembarked. The vehicles were all from
the same company, although had different paintings. Ricardinho began to wonder how many ways
that line could be formed using buses and minibuse from that company.
Each bus is 10 meters long, each minibus is 5 meters long. Given the total length of a line of buses
and minibuses, and the number of different colors each buse or minibus may be painted, Ricardinho
wants to know in how many ways such a line can be formed.
Input
The input contains several test cases. Each test case is composed of a single line, containing three
integers N, K and L, representing respectively the total length, in meters, of the line Ricky is con-sidering, K indicates the number of different colors for micro-buses, and L represents the number of
different colors for buses. Note that, as integers N , K and L may be very large, the use of 64 bits
integers is recommended.
Output
As the number of different ways of forming the line can be very large, Ricardinho is interested in the
last 6 digits of that quantity. Thus, your for each test case your program must produce a single line
containing exactly 6 digits, corresponding to the last digits of the solution.
Restrictions
• 5 ≤ N ≤ 10
15
and N is multiple of 5
• 1 ≤ K ≤ 10
15
• 1 ≤ L ≤ 10
15
Examples
Input
25 5 5
5 1000 1000
20 17 31
15 9 2
Output
006000
001000
111359
000765
#include <iostream>
#include <stdio.h>
#include <queue>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <queue>
#include <set>
#include <algorithm>
#include <map>
#include <stack>
#include <math.h>
#define Max(a,b) ((a)>(b)?(a):(b))
#define Min(a,b) ((a)<(b)?(a):(b))
using namespace std ;
typedef long long LL ;
const int M= ;
const LL Mod= ;
LL A[M] ;
struct Mat{
LL num[][] ;
Mat(){} ;
Mat(int a11 ,int a12 ,int a21 ,int a22){
num[][]=a11 ;
num[][]=a12 ;
num[][]=a21 ;
num[][]=a22 ;
}
Mat operator *(Mat &B){
Mat ans(,,,) ;
for(int i= ;i<= ;i++)
for(int j=;j<= ;j++)
for(int k=;k<=; k++){
ans.num[i][j]=ans.num[i][j]+num[i][k]*B.num[k][j] ;
if(ans.num[i][j]>=Mod)
ans.num[i][j]%=Mod ;
}
return ans ;
}
};
Mat Pow(Mat X ,LL y){
Mat ans=Mat(,,,) ;
for(;y;y>>=){
if(y&)
ans=ans*X ;
X=X*X ;
}
return ans ;
}
LL a[] ;
int main(){
LL N ,K ,L ;
while(cin>>N>>K>>L){
N/= ;
Mat A(K%Mod ,L%Mod , ,) ;
a[]=K%Mod ;
a[]=(((K%Mod)*(K%Mod))%Mod+L%Mod)%Mod ;
if(N==)
printf("%06d\n",(int)a[]) ;
else if(N==)
printf("%06d\n",(int)a[]) ;
else{
A=Pow(A,N-) ;
LL ans=(A.num[][]*a[]%Mod+A.num[][]*a[]%Mod)%Mod ;
printf("%06d\n",(int)ans) ;
}
}
return ;
}
UVA12653 Buses的更多相关文章
- CF459C Pashmak and Buses (构造d位k进制数
C - Pashmak and Buses Codeforces Round #261 (Div. 2) C. Pashmak and Buses time limit per test 1 seco ...
- codeforces 459C Pashmak and Buses 解题报告
题目链接:http://codeforces.com/problemset/problem/459/C 题目意思:有 n 个 students,k 辆 buses.问是否能对 n 个students安 ...
- ural 1434. Buses in Vasyuki
1434. Buses in Vasyuki Time limit: 3.0 secondMemory limit: 64 MB The Vasyuki University is holding a ...
- cf459C Pashmak and Buses
C. Pashmak and Buses time limit per test 1 second memory limit per test 256 megabytes input standard ...
- codeforces #261 C题 Pashmak and Buses(瞎搞)
题目地址:http://codeforces.com/contest/459/problem/C C. Pashmak and Buses time limit per test 1 second m ...
- Problem J: Island Buses
主要题意是:大海之间有岛,有的岛之间有桥,问你岛的个数,桥的个数,以及没有桥联通岛的个数,其中最后一次输入的没有回车,不注意的话最后一次会被吞,第二,桥的两端的标记是“X”(X也代表陆地),“X”的四 ...
- Codeforces 665A. Buses Between Cities 模拟
A. Buses Between Cities time limit per test: 1 second memory limit per test: 256 megabytes input: s ...
- Educational Codeforces Round 12 A. Buses Between Cities 水题
A. Buses Between Cities 题目连接: http://www.codeforces.com/contest/665/problem/A Description Buses run ...
- cf 459c Pashmak and Buses
E - Pashmak and Buses Time Limit:1000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I ...
随机推荐
- select case when
SELECT CASE WHEN dc.defect_code_name IS NOT NULL THEN dc.defect_code_name WHEN sf.second_defect_leve ...
- jQuery网页右侧固定层显示隐藏在线qq客服代码
CSS代码: @charset "utf-8"; ;;} html,body{font-size:12px;font-family:"微软雅黑";outline ...
- 一个平时写程序通用的Makefile样例
//需要目标名和程序名字相同 .PHONY:clean all //伪目标 CC=gcc CFLAGS=-Wall -g BIN= //目标 all:$(BIN) %.o:%.c $(CC) $(CF ...
- 【性能测试】性能测试总结<三>
常见性能测试工具: 性能测试工具,从理论上来讲在性能测试过程中使用到的所有工具都可以称其为性能测试工具,通常分为以下几类: 说明: 服务器端性能测试工具:需要支持产生压力和负载,录制和生成脚本,设置和 ...
- 【linux】/etc/passwd文件
/etc/passwd文件内容格式 /etc/passwd是保存用户信息的文件. 格式:用户名: 密码 : uid : gid :用户描述:主目录:登陆shell 举个例子: root:x:0:0: ...
- DateGridView中添加下拉框列并实现数据绑定、更改背景色
1.添加下拉框 代码实现==> using System; using System.Collections.Generic; using System.Windows.Forms; names ...
- 127 Word Ladder
Given two words (beginWord and endWord), and a dictionary's word list, find the length of shortest t ...
- 解密:wp-includes/load.php
描述:定义加载 WP 所需要的函数.1)wp_unregister_GLOBALS(),关闭’GLOBALS’, ‘_GET’, ‘_POST’, ‘_COOKIE’, ‘_REQUEST’, ‘_S ...
- C产品狗
作者:郭琦链接:https://www.zhihu.com/question/29342383/answer/110823046来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非商业转载请注明 ...
- catalan---卡特兰数(小结)
(关于卡特兰数的详细介绍)http://baike.baidu.com/view/2499752.htm 下面有练习的题目: 经过测试,_int64/long long 最大只能表示到33位,超过这个 ...