全部评论
第一题AC了,第二题不会做 import java.util.*;
public class NO1 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
String s = in.nextLine();
Map<String,Integer> map = new HashMap<>();
map.put("()", 1);
int result = helper(s,map);
System.out.println(result);
}
public static int helper(String s , Map<String,Integer> map){
if(map.containsKey(s)){
return map.get(s);
}
int count = 0;
int result = 0;
for(int i = 0 ; i < s.length(); i ++){
if(s.charAt(i) == '('){
count++;
}else{
count--;
}
if(count >= 0 && s.charAt(i) == ')'){
String left = s.substring(1,i);
String right = s.substring(i+1,s.length());
result+= helper(left+right,map);
}
}
map.put(s,result);
return result;
}
}
神奇数字 55555 js版本 为毛只有20%?
第一题最后30秒做出来了,提交没时间。。。
#第一题
import math
n = input()
n=int(n)
x=(-1+(1+8*n)**0.5)/2
print(math.ceil(x))#向上取整
# 第一题 AC
import math
x = int(input())
a = math.sqrt(2*x+1/4)-0.5 a = math.ceil(a) print(a)
#第二题 20%
print(n*n+n*(n-1))
猝
相关推荐
![](https://static.nowcoder.com/fe/file/oss/1716965564844UEBJN.png)
![](https://static.nowcoder.com/fe/file/oss/1716965585666UBBME.png)
深信服
| 校招
| 14个岗位
点赞 评论 收藏
分享