hdu2276---Kiki & Little Kiki 2(矩阵)】的更多相关文章

pid=2276">题目链接 题意:有n盏灯.编号从1到n.他们绕成一圈,也就是说.1号灯的左边是n号灯.假设在第t秒的时候,某盏灯左边的灯是亮着的,那么就在第t+1秒的时候改变这盏灯的状态.输入m和初始灯的状态.输出m秒后,全部灯的状态. 思路:事实上每盏灯的状态之和前一盏和自己有关.所以能够得到一个关系矩阵.如果有6盏灯,因此能够得到关系矩阵例如以下:  (1, 0, 0, 0, 0, 1)  (1, 1, 0, 0, 0, 0)  (0, 1, 1, 0, 0, 0)  (0, 0,…
pid=300">Kiki & Little Kiki 2 时间限制:5000 ms  |  内存限制:65535 KB 难度:4 描写叙述 There are n lights in a circle numbered from 1 to n. The left of light 1 is light n, and the left of light k (1< k<= n) is the light k-1.At time of 0, some of them tu…
Description There are n lights in a circle numbered from 1 to n. The left of light 1 is light n, and the left of light k (1< k<= n) is the light k-1.At time of 0, some of them turn on, and others turn off. Change the state of light i (if it's on, tu…
题意: 给一个有n*m 个格子的棋盘,将一个硬币放在右上角一格,每次可以往左/下/左下移动一格,碰到不能移动的局面者输. 思路: 找P/N状态.先将(n,1)归为P状态,那么能一步到达此位置的有3个位置,分别是其上/右/右上的格子.根据这个规律来找,在整个棋盘的格子上标上P和N.可以发现,棋盘上是有规律的,若提供的n和m皆为奇数,则先手输:否则先手赢. #include <iostream> #include <cstdio> using namespace std; int ma…
Kiki & Little Kiki 2 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3078    Accepted Submission(s): 1642 Problem Description There are n lights in a circle numbered from 1 to n. The left of lig…
用户添加修改删除 1 useradd添加用户 添加一个新用户hehe,指定uid为3000,家目录为/home/haha [root@qdlinux ~]# useradd -u 3000 -d /home/haha hehe hehe:x:3000:3000::/home/haha:/bin/bash [root@qdlinux ~]# ls /home/ haha 这里-u是uid,-g可以指定组id,不定值系统自动分配,-G可以指定附加组,如果不想让用户登录系统可以指定参数-s /sbin…
Kiki & Little Kiki 2 转载自:点这里 [题目链接]Kiki & Little Kiki 2 [题目类型]矩阵位运算 &题意: 一排灯,开关状态已知,每过一秒:第i个灯会根据刚才左边的那个灯的开关情况变化,如果左边是开的,它就会变化,如果是关的,就保持原来状态.问m秒后的状态. 第1个的左边是最后一个. &题解: 题目给定一个01字符串然后进行m次的变换,变换的规则是:如果当前位置i的左边是1(题目说了是个圆,下标为0的左边是n-1),那么i就要改变状态0…
Kiki & Little Kiki 2 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1659    Accepted Submission(s): 837 Problem Description There are n lights in a circle numbered from 1 to n. The left of ligh…
题目:Kiki & Little Kiki 2 链接:http://acm.hdu.edu.cn/showproblem.php?pid=2276 分析: 1)如果前一盏灯亮着,则改变这一盏灯的状态.灯用0和1表示亮和不亮. 2)0和0=0,0和1=1,1和0=1,1和1=0:这是异或,或者说 (左边的状态+原来的状态)%2=现在的状态,或者表示为(左边的状态+原来的状态)&1=现在的状态. 3)构造矩阵,快速幂优化.$T = \left[ \begin{array}{cccccc} 1…
Problem Description There are n lights in a circle numbered from 1 to n. The left of light 1 is light n, and the left of light k (1< k<= n) is the light k-1.At time of 0, some of them turn on, and others turn off. Change the state of light i (if it'…
蒟蒻的我还需深入学习 链接:传送门 题意:给出一个长度为 n,n 不超过100的 01 串 s ,每当一个数字左侧为 1 时( 0的左侧是 n-1 ),这个数字就会发生改变,整个串改变一次需要 1s ,询问 M s 后此串变为什么样子,例如 0101111 ,1s 后变为 1111000 思路: 根据题意可以得到这样一个规律 s[ i ] = ( s[ i - 1 ] + s[ i ] ) % 2,特别的 s[ 0 ] = ( s[ n-1 ] + s[ 0 ] ) % 2 ( s[ ] 不再考…
题目链接 n个灯围成一圈, 1左边是n. 有两种状态, 1是亮, 0是不亮. 如果一个灯, 它左边的灯是亮的, 那么下一时刻这个灯就要改变状态, 1变为0, 0变为1. 给出初始状态和时间t, 问t时刻每个灯的状态是什么. ai = (a(i-1)+ai)%2, 根据这个构建矩阵. /* 1 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 1 1 0 0…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2276 题目意思:给予一个01字符串,表示一串灯的明亮状态,现在每过一秒,如何这个灯的左边的灯是亮的,我们就改变他的明亮状态.(从左往右依次更新)注:第一个的左边是最后一个(即0的左边是n-1),问n秒后所有灯的明亮状态. 思路:采用矩阵快速幂啊!这个题十分有意思,采用了位运算,是真的没有想到. 以上是以样例一(0101111)为例的系数矩阵,我们发现对于相邻的两位只存在四种情况00,01,10,11…
描述 There are n lights in a circle numbered from 1 to n. The left of light 1 is light n, and the left of light k (1< k<= n) is the light k-1.At time of 0, some of them turn on, and others turn off. Change the state of light i (if it's on, turn off it…
题意是:给出一串01串,每一秒,每个位置得灯会根据左边那个灯得状态进行改变,(第一个得左边为最后一个)如果左边为1,那么自己就会改变状态,左边为0则不用,问n秒改01串的状态 ///// 首先,我们发现,a[2]=(a[1]+a[2])%2;, 可以用矩阵快速幂来算出结果. 同时我们发现 (1+1)%2和1^1结果一样,1*1和1&1结果一样,所以相乘函数改下就行了 代码: #include<bits/stdc++.h>using namespace std;typedef long…
题目传送:http://acm.hdu.edu.cn/showproblem.php?pid=2147 Problem Description Recently kiki has nothing to do. While she is bored, an idea appears in his mind, she just playes the checkerboard game.The size of the chesserboard is n*m.First of all, a coin i…
Hello Kiki Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1943    Accepted Submission(s): 693 Problem Description One day I was shopping in the supermarket. There was a cashier counting coins s…
kiki's game Time Limit: 1000MS   Memory Limit: 10000KB   64bit IO Format: %I64d & %I64u Submit Status Description Recently kiki has nothing to do. While she is bored, an idea appears in his mind, she just playes the checkerboard game.The size of the…
kiki's game Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 40000/10000 K (Java/Others) Total Submission(s): 8127 Accepted Submission(s): 4833 Problem Description Recently kiki has nothing to do. While she is bored, an idea appears in his mind,…
kiki's game Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 40000/1000 K (Java/Others)Total Submission(s): 5094    Accepted Submission(s): 2985 Problem Description Recently kiki has nothing to do. While she is bored, an idea appears in his mi…
kiki's game Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 40000/10000 K (Java/Others)Total Submission(s): 8041    Accepted Submission(s): 4781 Problem Description Recently kiki has nothing to do. While she is bored, an idea appears in his m…
欢迎参加——BestCoder周年纪念赛(高质量题目+多重奖励) kiki's game Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 40000/10000 K (Java/Others)Total Submission(s): 8013    Accepted Submission(s): 4758 Problem Description Recently kiki has nothing to do. While she i…
Hello Kiki Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 247 Accepted Submission(s): 107   Problem Description One day I was shopping in the supermarket. There was a cashier counting coins serio…
KiKi's K-Number Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 211 Accepted Submission(s): 88   Problem Description For the k-th number, we all should be very familiar with it. Of course,to kiki…
kiki's game Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 40000/10000 K (Java/Others)Total Submission(s): 10763    Accepted Submission(s): 6526 Problem Description Recently kiki has nothing to do. While she is bored, an idea appears in his…
Recently kiki has nothing to do. While she is bored, an idea appears in his mind, she just playes the checkerboard game.The size of the chesserboard is n*m.First of all, a coin is placed in the top right corner(1,m). Each time one people can move the…
Hello Kiki Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Problem Description One day I was shopping in the supermarket. There was a cashier counting coins seriously when a little kid running and singing "门前大桥下游过一…
HDU.2147 kiki's game (博弈论 PN分析) 题意分析 简单的PN分析 博弈论快速入门 代码总览 #include <bits/stdc++.h> using namespace std; int main() { int n,m; while(scanf("%d %d",&n,&m) != EOF){ if(n == 0 && m == 0) break; if(n%2 && m%2){ printf(&q…
KiKi's K-Number Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2393    Accepted Submission(s): 1101 Problem Description For the k-th number, we all should be very familiar with it. Of course,to…
Hello Kiki Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1717    Accepted Submission(s): 599 Problem Description One day I was shopping in the supermarket. There was a cashier counting coins…