QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#39590#2933. Sequinary NumeralsCJWA 3ms3968kbC++720b2022-07-12 13:59:592022-07-12 14:00:01

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-07-12 14:00:01]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:3968kb
  • [2022-07-12 13:59:59]
  • 提交

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'