[Offer收割]编程练习赛24 register

Ended

Participants:356

Verdict:Accepted
Score:100 / 100
Submitted:2017-08-27 14:17:07

Lang:GCC

Edit
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
#include <stdio.h>
#include <stdlib.h>
#define maxn 100000
long a[maxn+10];
int main()
{
    long n,i,q,mode,x,y,ans;
    scanf("%ld",&n);
    for (i=1;i<=n;i++)
        scanf("%ld",&a[i]);
    scanf("%ld",&q);
    while (q)
    {
        q--;
        scanf("%ld",&mode);
        if (mode==1)
        {
            scanf("%ld",&x);
            ans=0;
            while (x<=n)
            {
                ans++;
                x+=a[x];
            }
            printf("%ld\n",ans);
        }
        else
        {
            scanf("%ld%ld",&x,&y);
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX