Codeforces Round #233 (Div. 2), problem: (A) Pages :
http://codeforces.com/contest/399/problem/A
Codeforces Round #233 (Div. 2), problem: (A) Pages solution :
#include <iostream>
#include <cstdio>
using namespace std;
int main() {
int n, p, k;
scanf("%d%d%d", &n, &p, &k);
if(p-k>1) {
printf("<< ");
for(int i=p-k; i<p; i++) printf("%d ", i);
}
else if(p-k<=1) for(int i=1; i<p; i++) printf("%d ", i);
printf("(%d) ", p);
if(p+k<n){
for(int i=p+1; i<=p+k; i++) printf("%d ", i);
printf(">> ");
}
else if(p+k>=n) for(int i=p+1; i<=n; i++) printf("%d ", i);
return 0;
}
No comments:
Post a Comment