励志成为网管的程序猿 level
获赞
8
粉丝
1
关注
2
看过 TA
0
西安工程大学
2019
C++
IP属地:未知
暂未填写个人简介
私信
关注
2019-04-13 17:32
已编辑
西安工程大学 C++
前两个AC第三个时间不够没写完过了17.6%   有啥通俗易懂的思路嘛      编辑一下   不会用动态规划,第一题代码。。。      #include<iostream> using namespace std; #include<string>  int Get(string& s1, string& s2) {     int ret = 0;     if (s1.size() == s2.size())     {         if (s1.c_str() == s2.c_str())         {             ret...
希望有个好结果:层级遍历 import java.util.LinkedList; import java.util.Scanner; public class Main {    public static void main(String[] args) {       Scanner in = new Scanner(System.in);       String s = in.next();       String[] split = s.split(",");       int x = Integer.valueOf(split[0]);       int y = Integer.valueOf(split[1]);       LinkedList<Integer> list = new LinkedList<>();       int times = 0;       int count = 0;       int temp = x;       while(temp != y) {           list.add(temp+1);           list.add(temp-1);           list.add(temp*2);           if(count == 0) {               count = list.size();               times++;           }           temp = list.removeFirst();           count--;       }       System.out.println(times);    } }
投递快手等公司7个岗位
0 点赞 评论 收藏
分享

创作者周榜

更多
关注他的用户也关注了:
牛客网
牛客网在线编程
牛客网题解
牛客企业服务