-
Notifications
You must be signed in to change notification settings - Fork 0
/
2019.3.3AC
113 lines (108 loc) · 2.43 KB
/
2019.3.3AC
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#include<iostream>
#include<vector>
#include<algorithm>
#include<stdio.h>
using namespace std;
int check(int b);
string yihuo(string a,string b);
struct hard_disk{
int num;
string data;
};
vector<hard_disk> hd;
int n,s,l,m,b;
string ans;
int block_num=0;//总块数
//bool paixu(hard_disk a,hard_disk b){ return a.num<b.num;}
int main()
{
//ios::sync_with_stdio(false);
cin>>n>>s>>l;
struct hard_disk temp;
for(int i=0;i<l;i++)
{
cin>>temp.num;
cin.get();
char tmp[85000];
fgets(tmp,85000,stdin);
temp.data=tmp;
hd.push_back(temp);
}
if(l!=0)
{
block_num=hd.front().data.size()/8*(n-1);
}
//cout<<block_num<<'\n';
//sort(hd.begin(),hd.end(),paixu);
cin>>m;
for(int i=0;i<m;i++)
{
cin>>b;
if(check(b))
cout<<ans<<endl;
else cout<<'-'<<endl;;
}
return 0;
}
int check(int b)
{
if(b>=block_num)
return 0;
int line=b/(s*(n-1));//目标块所在条带行
int block=n-line%n-1;//条带所在块号
int ans_block;
int ans_tiaodai;
if((n-1-block)*s>=b%(s*(n-1))+1)//右边
{
ans_block=b%(s*(n-1))/s+1+block;
ans_tiaodai=(b%(s*(n-1))+1)%s;
ans_tiaodai=ans_tiaodai==0?s:ans_tiaodai;
}
else
{
ans_block= (b%(s*(n-1))-(n-1-block)*s)/s;
ans_tiaodai=(b%(s*(n-1))+1-(n-1-block)*s)%s;
ans_tiaodai=ans_tiaodai==0?s:ans_tiaodai;
}
//cout<<ans_block<<' '<<ans_tiaodai<<endl;
for(unsigned int i=0;i<hd.size();i++)
{
if(hd[i].num==ans_block)
{
int start=line*s+ans_tiaodai;
ans=hd[i].data.substr(8*(start-1),8);
return 1;
}
}
if(n-l>1)
return 0;
ans="00000000";
int start=line*s+ans_tiaodai;
for(unsigned int i=0;i<hd.size();i++)
{
string tmp=hd[i].data.substr(8*(start-1),8);
ans=yihuo(ans,hd[i].data);
}
return 1;
}
string yihuo(string a,string b)
{
string c;
int a_temp,b_temp;
int temp;char ch;
for(unsigned int i=0;i<a.size();i++)
{
if(a[i]>='0'&&a[i]<='9')
a_temp=a[i]-48;
else a_temp=a[i]-'A'+10;
if(b[i]>='0'&&b[i]<='9')
b_temp=b[i]-48;
else b_temp=b[i]-'A'+10;
temp=(a_temp^b_temp);
if(temp>=0&&temp<=9)
ch=(char)(temp+48);
else ch=(char)(temp-10+'A');
c+=ch;
}
return c;
}