Language: C++

#include<iostream>
#include<string>
#include<cmath>
#include<vector>
#include<map>
using namespace std;
pair<int,int>tasu(pair<int,int>a,pair<int,int>b){
	long long  a1=a.first,a2=a.second,b1=b.first,b2=b.second;
	long long  ta2=a2,tb2=b2;
	a1*=tb2,a2*=tb2;
	b1*=ta2,b2*=ta2;
	long long  c1=a1+b1,c2=a2;
	for(int i=2;i<=1000000;i++){
	if(i==0||i==1||i==-1)continue;
	if(c1%i==0&&c2%i==0){
		c1/=i,c2/=i;
		i=-2;
	}
	}
	pair<int,int>c=make_pair(c1,c2);
	return c;
}
int main(){
	string n;
	//pair<int,int>a1,a2;
	//a1=make_pair(2,5);
	//a2=make_pair(3,6);
//	pair<int,int> tmp=tasu(a1,a2);
	//cout<<tmp.first<<" "<<tmp.second<<endl;

	while(true){
	cin>>n;
	if(n=="#")break;
	vector<char>dir(0);
	for(int i=0;i<n.size();i++){
	if(n[i]=='w')dir.push_back('w');
	if(n[i]=='n')dir.push_back('n');
	}
	reverse(dir.begin(),dir.end());
	pair<int,int> ans=make_pair(0,1);
	if(dir[0]=='w')ans.first=90;
	for(int i=1;i<dir.size();i++){
		pair<int,int>tmp;
		if(dir[i]=='w'){
		tmp=make_pair(90,pow(2,i));
		ans=tasu(ans,tmp);
		}
		else if(dir[i]=='n'){
		tmp=make_pair(-90,pow(2,i));
		ans=tasu(ans,tmp);
		}
	}
	if(ans.second==1)cout<<ans.first<<endl;
	else if(ans.first==0)cout<<0<<endl;
	else cout<<ans.first<<"/"<<ans.second<<endl;
	}
	return 0;
}


/*#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
int m,t,p,r;
struct team{
int time[200];
bool ok[200];
int id;
int ac;
};
//team a,team b
int oror(team a,team b){//aのほうが強ければ1,bなら0,同じなら2
if(a.ac>b.ac)return 1;
else if(a.ac<b.ac)return 0;
int at=0,bt=0;
for(int i=0;i<=p;i++){
if(a.ok[i]==true)at+=a.time[i];
if(b.ok[i]==true)bt+=b.time[i];
}
if(at<bt)return 1;
else if(at>bt)return 0;
else return 2;
}
int main(){

	while(true){
	cin>>m>>t>>p>>r;
	if(m+t+p+r==0)break;
	vector<team>ta(0);
	ta.resize(200);

	for(int i=0;i<=t;i++)for(int j=0;j<200;j++)ta[i].time[j]=0,ta[i].ok[j]=0;
	for(int i=0;i<=t;i++)ta[i].id=i,ta[i].ac=0;
	for(int i=0;i<r;i++){
	int a,b,c,d;
	cin>>a>>b>>c>>d;//a:経過時間:bチーム番号c:問題番号j:0奈良正解それ以外不正解
	if(d==0){
	ta[b].time[c]+=a;
	ta[b].ac++;
	ta[b].ok[c]=true;
	}
	else {
	ta[b].time[c]+=20;
	}
	}
	ta.erase(ta.begin());
	for(int i=0;i<t;i++){
	for(int j=0;j<t;j++){
	if(oror(ta[i],ta[j])==1)swap(ta[i],ta[j]);
	if(oror(ta[i],ta[j])==2&&ta[i].id>ta[j].id)swap(ta[i],ta[j]);
	}
	}
	for(int i=0;i<t-1;i++){
	if(oror(ta[i],ta[i+1])!=2)cout<<ta[i].id<<",";
	else cout<<ta[i].id<<"=";
	}
	cout<<ta[t-1].id<<endl;
	}
	return 0;
}
//間違ったコード
/*#include<iostream>
#include<string>
#include<cmath>
#include<map>
using namespace std;
pair<int,int>tasu(pair<int,int>a,pair<int,int>b){
	int a1=a.first,a2=a.second,b1=b.first,b2=b.second;
	int ta2=a2,tb2=b2;
	a1*=tb2,a2*=tb2;
	b1*=ta2,b2*=ta2;
	int c1=a1+b1,c2=a2;
	for(int i=2;i<=10000;i++){
	if(i==0||i==1||i==-1)continue;
	if(c1%i==0&&c2%i==0){
		c1/=i,c2/=i;
		i=-2;
	}
	}
	pair<int,int>c=make_pair(c1,c2);
	return c;
}
int main(){
	string n;
	//pair<int,int>a1,a2;
	//a1=make_pair(2,5);
	//a2=make_pair(3,6);
//	pair<int,int> tmp=tasu(a1,a2);
	//cout<<tmp.first<<" "<<tmp.second<<endl;

	while(true){
	cin>>n;
	if(n=="#")break;
	bool f1;
	int cnt=0;
	pair<int,int>ans;
	if(n.substr(0,5)=="north")f1=1;
	else f1=0;//初めが北なら1,東なら0

	if(f1){
	ans=make_pair(45,1);
	for(int i=1;i<(int)n.size()-5;i++){
	if(n.substr(i,5)=="north"){cnt++;}
	}
	for(int i=1;i<=cnt;i++){
		pair<int,int>tmp=make_pair(-90,pow(2,i+1));
		ans=tasu(ans,tmp);
	}
	}
	else{
	ans=make_pair(45,1);
	int cnt=0;
	for(int i=1;i<n.size()-4;i++)if(n.substr(i,4)=="west")cnt++;
	for(int i=1;i<=cnt;i++){
	pair<int,int>tmp=make_pair(90,pow(2,i+1));
	ans=tasu(ans,tmp);
	}
	}
	if(n=="north")cout<<0<<endl;
	else if(n=="west")cout<<90<<endl;
	else cout<<ans.first<<"/"<<ans.second<<endl;
	}
	return 0;
}*/


/*#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
int m,t,p,r;
struct team{
int time[200];
bool ok[200];
int id;
int ac;
};
//team a,team b
int oror(team a,team b){//aのほうが強ければ1,bなら0,同じなら2
if(a.ac>b.ac)return 1;
else if(a.ac<b.ac)return 0;
int at=0,bt=0;
for(int i=0;i<=p;i++){
if(a.ok[i]==true)at+=a.time[i];
if(b.ok[i]==true)bt+=b.time[i];
}
if(at<bt)return 1;
else if(at>bt)return 0;
else return 2;
}
int main(){

	while(true){
	cin>>m>>t>>p>>r;
	if(m+t+p+r==0)break;
	vector<team>ta(0);
	ta.resize(200);

	for(int i=0;i<=t;i++)for(int j=0;j<200;j++)ta[i].time[j]=0,ta[i].ok[j]=0;
	for(int i=0;i<=t;i++)ta[i].id=i,ta[i].ac=0;
	for(int i=0;i<r;i++){
	int a,b,c,d;
	cin>>a>>b>>c>>d;//a:経過時間:bチーム番号c:問題番号j:0奈良正解それ以外不正解
	if(d==0){
	ta[b].time[c]+=a;
	ta[b].ac++;
	ta[b].ok[c]=true;
	}
	else {
	ta[b].time[c]+=20;
	}
	}
	ta.erase(ta.begin());
	for(int i=0;i<t;i++){
	for(int j=0;j<t;j++){
	if(oror(ta[i],ta[j])==1)swap(ta[i],ta[j]);
	if(oror(ta[i],ta[j])==2&&ta[i].id>ta[j].id)swap(ta[i],ta[j]);
	}
	}
	for(int i=0;i<t-1;i++){
	if(oror(ta[i],ta[i+1])!=2)cout<<ta[i].id<<",";
	else cout<<ta[i].id<<"=";
	}
	cout<<ta[t-1].id<<endl;
	}
	return 0;
}*/

Compiler output:
a.cc: In function 'int main()':
a.cc:39:9: error: 'reverse' was not declared in this scope
   39 |         reverse(dir.begin(),dir.end());
      |         ^~~~~~~