QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#39590 | #2933. Sequinary Numerals | CJ | WA | 3ms | 3968kb | C++ | 720b | 2022-07-12 13:59:59 | 2022-07-12 14:00:01 |
Judging History
answer
#include<iostream>
using namespace std;
#include<cmath>
#include<string>
#include<algorithm>
#include<sstream>
int main()
{
string s;
cin>>s;
long double res=0,n=0,le=0;
long int j=0,k=0,m=0,len=0,g=0,pos=0;
reverse(s.begin(),s.end());
for(int i=0;i<s.size();i++)
{
n=s[i]-'0';
if(i==0)
res+=n;
else
res+=pow(1.5,i)*n;
}
while(1)
{
if(j<res&&(j+1)>res)
{
le=res-j;
break;
}
if(j==res)break;
j++;
}
if(le!=0)
{
string t;
stringstream ss,tt;
ss<<le;
ss>>t;
pos=t.find(".");
t.erase(0,pos+1);
len=t.size()-pos+1;
tt<<t;
tt>>k;
m=pow(10,len);
g=__gcd(m,k);
k/=g;
m/=g;
cout<<j<<" "<<k<<"/"<<m;
}
else cout<<j;
}
詳細信息
Test #1:
score: 100
Accepted
time: 3ms
memory: 3724kb
input:
2101
output:
10
result:
ok single line: '10'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3968kb
input:
201
output:
5 1/2
result:
ok single line: '5 1/2'
Test #3:
score: -100
Wrong Answer
time: 2ms
memory: 3856kb
input:
2010211122112221202012
output:
16541 416661/500000
result:
wrong answer 1st lines differ - expected: '16541 873801/1048576', found: '16541 416661/500000'