Codeforce Round #223 Div2 C
→ Practice
You are registered for practice. You can solve problems unofficially. Results can be found in the contest status and in the bottom of standings.
→ Submit?
→ Problem tags
No tag edit access
1 #pragma comment(linker,"/STACK:102400000,102400000") 2 #include <cstdio> 3 #include <vector> 4 #include <cmath> 5 #include <queue> 6 #include <cstring> 7 #include <iostream> 8 #include <algorithm> 9 using namespace std; 10 #define INF 0x7fffffff 11 #define mod 1000000007 12 #define ll long long 13 #define maxn 1000025 14 #define pi acos(-1.0) 15 int n, m; 16 ll a[maxn], b[maxn], c[maxn]; 17 ll find(ll x){ 18 int l = 0, r = n - 1, mid; 19 while (l < r){ 20 mid = ((l + r) >> 1) + 1; 21 if (b[mid]<=x)l = mid; 22 else r = mid-1; 23 } 24 if (a[l] == -1)return find((x-b[l])%c[l]+1); 25 return a[l]; 26 } 27 int main(){ 28 ll x, s = 1; 29 int op, cnt; 30 scanf("%d", &n); 31 for (int i = 0; i < n; i++){ 32 scanf("%d", &op); 33 if (op == 1){ 34 scanf("%I64d", &x); 35 a[i] = x; 36 b[i] = s; 37 s++; 38 } 39 else{ 40 scanf("%I64d%d", &x, &cnt); 41 a[i] = -1; 42 b[i] = s; 43 c[i] = x; 44 s += x*cnt; 45 } 46 } 47 scanf("%d", &m); 48 while (m--){ 49 scanf("%I64d", &x); 50 printf("%I64d ",find(x)); 51 } 52 return 0; 53 }




浙公网安备 33010602011771号