HDU 4364——Matrix operation——————【模拟题】
Matrix operation
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 907 Accepted Submission(s): 384
In the MixColumns step, there is a state matrix, the four bytes of each column of the state are combined using an invertible linear transformation. The MixColumns function takes four bytes as input and outputs four bytes, where each input byte affects all four output bytes. Together with ShiftRows, MixColumns provides diffusion in the cipher.
During this operation, each column is multiplied by the known matrix that for the 128 bit key is:

The addition operation is defined as: xor.
The multiplication operation is defined as:
multiplication by 1 means no change
multiplication by 2 means shifting to the left
multiplication by 3 means shifting to the left and then performing xor with the initial unshifted value.
Notice:After each shifting, a conditional xor with 0x1B should be performed if the shifted value is larger than 0xFF.
The first line is an integer T (T <= 20000), indicating the test cases.
Then is the state matrix, each case followed by four lines, each line contains four bytes, separated by spaces.
#include<bits/stdc++.h>
using namespace std;
int key[4][4]={2,3,1,1,1,2,3,1,1,1,2,3,3,1,1,2};
int ini[4][4],ans[4][4];
int main(){
int t;
scanf("%d",&t);
while(t--){
for(int i=0;i<4;i++){
for(int j=0;j<4;j++){
scanf("%x",&ini[i][j]);
}
}
for(int i=0;i<4;i++){
for(int j=0;j<4;j++){
int a,tmp=0;
for(int k=0;k<4;k++){
if(key[i][k]==1){
a=ini[k][j];
}else if(key[i][k]==2){
a=ini[k][j];
a<<=1;
if(a>0xFF){
a^=0x1B;
a%=(0xFF+1);
}
}else if(key[i][k]==3){
a=ini[k][j];
a<<=1;
if(a>0xFF){
a^=0x1B;
a%=(0xFF+1);
}
a^=ini[k][j];
}
tmp^=a;
}
ans[i][j]=tmp;
}
}
for(int i=0;i<4;i++){
for(int j=0;j<4;j++){
printf("%02x%c",ans[i][j],j==3?'\n':' ');
}
}
if(t)
puts("");
}
return 0;
}
HDU 4364——Matrix operation——————【模拟题】的更多相关文章
- HDU 1262 寻找素数对 模拟题
题目描述:输入一个偶数,判断这个偶数可以由哪两个差值最小的素数相加,输出这两个素数. 题目分析:模拟题,注意的是为了提高效率,在逐个进行判断时,只要从2判断到n/2就可以了,并且最好用打表法判断素数. ...
- HDU 2093 考试排名 模拟题
解题报告: 题目描述:写一个程序给一个编程考试C++实时提交系统排名,给你的数据是题目的总数,每次错误提交罚的时间分,每位用户的姓名,然后是输入用户每题的完成情况,有一下几种情况,第一,输入只有一个正 ...
- HDU 2521 反素数 模拟题
解题报告:水题,直接附上代码,只是觉得这题的作者是不是吃饱了饭撑的,反素数的概念跟这题一点关系都没有. #include<cstdio> int judge1(int k) { ; ;i& ...
- HDU 1256 画8 模拟题
解题报告:这题我觉得题目有一个没有交代清楚的地方就是关于横线的字符的宽度的问题,题目并没有说,事实上题目要求的是在保证下面的圈高度不小于上面的圈的高度的情况下,横线的宽度就是等于下面的圈的高度. #i ...
- HDU 4022 Bombing STL 模拟题
人工模拟.. #include<stdio.h> #include<iostream> #include<algorithm> #include<vector ...
- hdu 4515 年月份模拟题
小Q系列故事——世界上最遥远的距离 Time Limit: 500/200 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others) ...
- HDU 3787 A+B 模拟题
解题报告:就是输入两个用逗号隔开的数字,求出这两个数字的和,并且用正常的方式输出来.直接写一个函数将一个包含逗号的数字转换成十进制的数返回就行了.这里推荐一个函数atoi(),参数是char*型的,然 ...
- HDU 4041 Eliminate Witches! (模拟题 ACM ICPC 2011亚洲北京赛区网络赛)
HDU 4041 Eliminate Witches! (模拟题 ACM ICPC 2011 亚洲北京赛区网络赛题目) Eliminate Witches! Time Limit: 2000/1000 ...
- HDU 4452 Running Rabbits (模拟题)
题意: 有两只兔子,一只在左上角,一只在右上角,两只兔子有自己的移动速度(每小时),和初始移动方向. 现在有3种可能让他们转向:撞墙:移动过程中撞墙,掉头走未完成的路. 相碰: 两只兔子在K点整(即处 ...
随机推荐
- Python中logging模块的基本用法
在 PyCon 2018 上,Mario Corchero 介绍了在开发过程中如何更方便轻松地记录日志的流程. 整个演讲的内容包括: 为什么日志记录非常重要 日志记录的流程是怎样的 怎样来进行日志记录 ...
- Ubuntu安装SHH服务
1.打开"终端窗口",输入"sudo apt-get update"-->回车-->"输入当前登录用户的管理员密码"--> ...
- C# 添加vertical 属性上下边框消失问题
点击这里的曲别针就好了.... 自定义控件主题..... #学习地址: http://www.cnblogs.com/anding/p/4993655.html
- python爬取抖音APP视频教程
本文讲述爬取抖音APP视频数据(本文未完,后面还有很多地方优化总结) 公众号回复:抖音 即可获取源码 1.APP抓包教程,需要用到fiddler fiddler配置和使用查看>>王者荣耀盒 ...
- Error: Duplicate key name 'PCS_STATS_IDX' (state=42000,code=1061) ----Hive schematool -initSchema -dbType mysql
schematool -initSchema -dbType mysqlMetastore connection URL: jdbc:mysql://localhost/metastore_db?cr ...
- my.宝石 --- --- ZC 收集
1. DT PT 头盔 太阳石 物理伤害+8 √ 月亮石 物理防御+12 √ 武器 太阳石 物理伤害+8 √ 舍利子 法术伤害+6 ...
- python django bootstrap_导入 201901
参考 http://www.liujiangblog.com/course/django/124 AdminLTE-2.4.5 http://www.liujiangblog.com/course/d ...
- 转 from __future__ import unicode_literals
转自 https://www.liaoxuefeng.com/wiki/001374738125095c955c1e6d8bb493182103fac9270762a000/0013868200230 ...
- Spring MVC自定义错误页面
在web.xml中添加: <error-page(其他属性404...省略咯)> <location>/error</location> </error-pa ...
- webstorm中.vue报错(es6语法报错)-转
1.webstorm中es6语法报错,解决方法: 打开 Settings => Languages & Frameworks => Javascript把 Javascript L ...