You are not logged in. Please login at www.codechef.com to post your questions!

×

ROTATION : getting WA

include<iostream>

define MOD 1000000009

using namespace std;

int a[100009];

int main() { int n,m,i; char x; int y,r,t; r=0; cin>>n>>m;

for(i=0;i<n;i++)
{
    cin>>a[i];
}

while(m--)
{
    cin>>x>>y;
    if(x=='C')
    {
        r=(r+y)%n;
    }
    else if(x=='A')
    {
        r=(r-y)%n;
    }
    else if(x=='R')
    {
        t=(r+y-1)%n;
        cout<<a[t]<<endl;
    }
}
return 0;

}

asked 16 Dec '14, 12:41

ak_24's gravatar image

3★ak_24
192
accept rate: 0%


have a look at this :-

ideone link

link

answered 16 Dec '14, 13:01

acodebreaker2's gravatar image

1★acodebreaker2
1.2k12
accept rate: 18%

thanks i misinterpreted mod operator

(16 Dec '14, 14:15) ak_243★
toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×21
×1

question asked: 16 Dec '14, 12:41

question was seen: 279 times

last updated: 16 Dec '14, 14:15