Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- #define nmax 1000005
- using namespace std;
- ifstream cin("robot3.in");
- ofstream cout("robot3.out");
- int p,t,a[10],k=0,nrc,n,dd,ds;
- char dir,cif;
- int main()
- {
- cin>>t;
- if(t==1)
- {
- do
- {
- cin>>dir;
- if(dir=='A')
- k++;
- }while(dir!='T');
- cout<<k;
- }
- else
- {
- if(t==2)
- {
- nrc=0;
- do
- {
- cin>>dir;
- if(dir=='D')
- {
- cin>>p;
- nrc=(nrc+p)%10;
- }
- if(dir=='S')
- {
- cin>>p;
- nrc=(nrc-p+10)%10;
- }
- if(dir=='A')
- cout<<nrc;
- }while(dir!='T');
- }
- else
- {
- if(t==3)
- {
- nrc=0;
- while(cin>>cif)
- {
- int x=cif-'0';
- dd=(x-nrc+10)%10;
- ds=(nrc-x+10)%10;
- if(dd==0 ||ds==0)
- {
- cout<<"A";
- }
- else
- if(dd<=ds)
- {
- cout<<"D"<<dd<<"A";
- }
- else
- {
- cout<<"S"<<ds<<"A";
- }
- nrc=x;
- }
- cout<<"T";
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement