题解 | #游游的整数切割#

游游的整数切割

https://www.nowcoder.com/practice/c01b07fe9623425a806c85cdb6f0e0f7

import java.io.*;
import java.util.*;
import java.math.BigInteger;

public class Main {
    static void solve() {
        String s = in.next();
        int n = s.length();
        int last=s.charAt(n-1)-'0';
        long ans=0;
        for(int i=0;i<n-1;i++) {
            int cur = s.charAt(i)-'0';
            if((cur+last)%2==0) ans++;
        }
        out.println(ans);
    }

    public static void main(String[] args) {
        solve();
        out.flush();
    }

    static FastReader in = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);

    static class FastReader {
        static BufferedReader br;
        static StringTokenizer st;

        FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            String str = "";
            while(st==null||!st.hasMoreElements()) {
                try {
                    str = br.readLine();
                }catch(IOException e) {
                    throw new RuntimeException(e);
                }
                st = new StringTokenizer(str);
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}

全部评论

相关推荐

点赞 评论 收藏
分享
05-29 22:11
门头沟学院 Java
Elastic90:抛开学历造假不谈,这公司的招聘需求也挺怪的,Java开发还要求你有图文识别、移动端开发和c++的经验,有点逆天了。
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
07-10 11:31
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务