QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#789441#9746. 平方根sunup15#AC ✓8ms10056kbC++202.7kb2024-11-27 20:22:022024-11-27 20:22:06

Judging History

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

  • [2024-11-27 20:22:06]
  • 评测
  • 测评结果:AC
  • 用时:8ms
  • 内存:10056kb
  • [2024-11-27 20:22:02]
  • 提交

answer

/*
2024-10-06 20:38:26
*/
#include<bits/stdc++.h>
#define int long long
#define lc p<<1
#define rc p<<1|1
using std::cin;
using std::cout;
using std::function;
using std::max, std::min, std::swap;
using std::vector, std::string, std::set, std::priority_queue, std::queue;
using PII = std::pair<int,int>;
using Grap = std::vector<std::vector<int>>;
using Grapw = std::vector<std::vector<PII>>;
const int inf = INT64_MAX, _ = 0;
const int N = 2e5 + 5;
int mod = 1e9 + 7;




void init() {
	
	
	
}




void solve() {

	string s;
	std::cin >> s;

	int n = s.size();
	
	for (int i = 0; i < n; i++) {
		if (s[i] == '1') {
			if (i + 1 < n && s[i + 1] == '1') {
				if (i + 2 < n && s[i + 2] == '1') {
					s[i + 1] = '0';
				}
			}
		}
	}
	
	std::vector<double> res;
	for (int i = 0; i < n; i++) {
		if (s[i] == '1') {
			if (i + 1 < n && s[i + 1] == '1') {
				res.push_back(2);
				i++;
			}
			else res.push_back(1);
		}
	}
	
	double ans = 0;
	double add1 = 1;
	double add2 = sqrt(2);
	for (auto v : res) {
		if (v == 1) ans += add1;
		else ans += add2;
	}

	printf("%.10lf", ans);	
	
}





signed main() {
	init();
	// 超时了,优化一下cin输入速度  如果使用了这个,不能同时使用cin 和 scanf
	// in out stream :: sync_with_stdio(flase), cin.tie(0);
	std::ios::sync_with_stdio(false), std::cin.tie(0);
	
	int T = 1;
//	std::cin >> T;
	while (T--) solve();
	
	return (0^_^0);
}

/*
1.深呼吸,不要紧张,慢慢读题,读明白题,题目往往比你想的简单。
2.暴力枚举:枚举什么,是否可以使用一些技巧加快枚举速度(预处理、前缀和、数据结构、数论分块)。
3.贪心:需要排序或使用数据结构(pq)吗,这么贪心一定最优吗。
4.二分:满足单调性吗,怎么二分,如何确定二分函数返回值是什么。
5.位运算:按位贪心,还是与位运算本身的性质有关。
6.数学题:和最大公因数、质因子、取模是否有关。
7.dp:怎么设计状态,状态转移方程是什么,初态是什么,使用循环还是记搜转移。
8.搜索:dfs 还是 bfs ,搜索的时候状态是什么,需要记忆化吗。
9.树上问题:是树形dp、树上贪心、或者是在树上搜索。
10.图论:依靠什么样的关系建图,是求环统计结果还是最短路。
11.组合数学:有几种值,每种值如何被组成,容斥关系是什么。
12.交互题:log(n)次如何二分,2*n 次如何通过 n 次求出一些值,再根据剩余次数求答案。
13.如果以上几种都不是,多半是有一个 point 你没有注意到,记住正难则反。
*/

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3720kb

input:

1100110111

output:

4.8284271247

result:

ok found '4.828427125', expected '4.828427125', error '0.000000000'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3836kb

input:

0

output:

0.0000000000

result:

ok found '0.000000000', expected '0.000000000', error '-0.000000000'

Test #3:

score: 0
Accepted
time: 0ms
memory: 4076kb

input:

1

output:

1.0000000000

result:

ok found '1.000000000', expected '1.000000000', error '0.000000000'

Test #4:

score: 0
Accepted
time: 3ms
memory: 4296kb

input:

000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

0.0000000000

result:

ok found '0.000000000', expected '0.000000000', error '-0.000000000'

Test #5:

score: 0
Accepted
time: 6ms
memory: 9628kb

input:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

output:

500000.4142135624

result:

ok found '500000.414213562', expected '500000.414213562', error '0.000000000'

Test #6:

score: 0
Accepted
time: 8ms
memory: 9124kb

input:

010101111011001000011101100000011110101010000110011110101010111011010011100001100000001011100111110000100101100011101101000100110100111101001100011000101000000101011101000011011001111011101101100010110110001111011001010100110011111101000010010011011101100001101001101010011011100110101001101111010101...

output:

367851.9867876115

result:

ok found '367851.986787612', expected '367851.986787086', error '0.000000000'

Test #7:

score: 0
Accepted
time: 0ms
memory: 10056kb

input:

000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

299931.3137084990

result:

ok found '299931.313708499', expected '299931.313708499', error '0.000000000'

Extra Test:

score: 0
Extra Test Passed