QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#797303 | #8841. North North West | AA_Surely# | AC ✓ | 0ms | 3628kb | C++23 | 521b | 2024-12-02 20:29:24 | 2024-12-02 20:29:25 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
while(1){
string s;
cin >> s;
if(s == "#") break;
int a = 0 , b = 1;
for(int i = (int)s.size()-1 ; i >= 0 ; ){
if(s[i] == 'h'){
if(i < (int)s.size() - 1 - 1){
a = a * 2 - 90;
}
b *= 2;
i -= 5;
}
else{
a = a * 2 + 90;
b *= 2;
i -= 4;
}
}
b /= 2;
int g = gcd(a , b);
a /= g , b /= g;
cout << a;
if(b > 1){
cout << "/" << b;
}
cout << endl;
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3628kb
input:
north west northwest northnorthwest westwestwestnorth #
output:
0 90 45 45/2 315/4
result:
ok 5 tokens
Test #2:
score: 0
Accepted
time: 0ms
memory: 3568kb
input:
north west northwest northnorthwest westwestwestnorth westnorth westwestwestnorthwest west northwest northnorthnorthwestnorth northwestnorthwest westwestwestnorth northwestnorth north westnorth westnorthwestnorthwestwestnorthwestwestnorth northnorthwestnorthwestwestwestnorthnorthnorthwestwestnorthno...
output:
0 90 45 45/2 315/4 45 675/8 90 45 45/8 225/4 315/4 45/2 0 45 16335/256 286965/16384 1188585/16384 70065/1024 59985/2048 45/128 4005/64 5085/256 34785/1024 585/32 45/4096 765/64 225/32 974925/65536 2386665/32768 771075/131072 90 3778065/65536 20745/256 92115/1024 2835/32
result:
ok 36 tokens