-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathqrp1.cpp
42 lines (34 loc) · 845 Bytes
/
qrp1.cpp
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
#include <fstream>
#include <vector>
#include <string>
int main()
{
std::ifstream infile("input.txt");
std::ofstream outfile("output.txt");
int T;
infile>>T;
for(int t=1; t<=T; t++) {
int N, K;
unsigned long long int V;
std::vector< std::string > campuses;
infile>>N>>K>>V;
std::string cm;
for(int i=0; i<N; i++) {
infile>>cm;
campuses.push_back(cm);
}
int rem = ((V-1)*K) % N;
outfile<<"Case #"<<t<<":";
for(int i=0; i<K-(N-rem); i++) {
outfile<<" "<<campuses[i];
}
int tail = (rem+K > N) ? N : rem+K;
for(int i=rem; i<tail; i++) {
outfile<<" "<<campuses[i];
}
outfile<<std::endl;
}
infile.close();
outfile.close();
return 0;
}