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

游游的整数切割

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());
        }
    }
}

全部评论

相关推荐

CrazyBucket:我今天下午也做梦在招聘会上面试一家小厂,给自己气笑了
点赞 评论 收藏
分享
joe2333:怀念以前大家拿华为当保底的日子
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务