Contest Duration: - (local time) (100 minutes) Back to Home
Official

## A - Signed Difficulty Editorial by en_translator

Compute it just as the problem statement instructs.

First, receive an input as a string type (like string in C++); let call this $$S$$.

Since the last letter of $$S$$ represents $$Y$$, so store $$Y$$.

The last two characters of $$S$$ is unnecessary for the output; delete it.

Then,

• append - to $$S$$ if $$0 \leq Y \leq 2$$;
• append + to $$S$$ if $$7 \leq Y \leq 9$$.

Finally, output $$S$$.

Sample code in C++:

#include<bits/stdc++.h>
using namespace std;

signed main(){
string s;
cin>>s;

int n=s.size();//let n be the length of s
int y=s[n-1]-'0';

s=s.substr(0,n-2);
// obtain (n-2) consecutive characters, beginning from the 0-th character, from s; that is, remove the last two characters.

if(y<=2){
s+='-';
}else if(y>=7){
s+='+';
}

cout<<s<<endl;

return 0;
}


posted:
last update: