题解 | #[NOIP2008]ISBN号码#

[NOIP2008]ISBN号码

http://www.nowcoder.com/practice/95712f695f27434b9703394c98b78ee5

import java.util.Scanner;
import java.lang.String;
public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] isbn=sc.nextLine().split("-");//分开
        int one=Integer.parseInt(isbn[0]);
        int two=Integer.parseInt(isbn[1]);
        int three=Integer.parseInt(isbn[2]);
        int count1=one*1;
        int count2=(two/100)*2+(two%100/10)*3+(two%10)*4;
        int count3=(three/10000)*5+(three%10000/1000)*6+(three%1000/100)*7+(three%100/10)*8+(three%10)*9;
        int count=(count1+count2+count3)%11;
        if(count==10)
        {
            if(isbn[3].equals("X"))
            {
                 System.out.println("Right");
            }else{
                System.out.println(one+"-"+two+"-"+three+"-X");
            }
        }else{
            if(isbn[3].equals(String.valueOf(count)))
            {
                System.out.println("Right");
            }else{
                System.out.println(one+"-"+two+"-"+three+"-"+count);
            }
        }
    }
}

全部评论

相关推荐

05-07 17:58
门头沟学院 Java
wuwuwuoow:1.简历字体有些怪怪的,用啥写的? 2.Redis 一主二从为什么能解决双写一致性? 3.乐观锁指的是 SQL 层面的库存判断?比如 stock > 0。个人认为这种不算乐观锁,更像是乐观锁的思想,写 SQL 避免不了悲观锁的 4.奖项证书如果不是 ACM,说实话没什么必要写 5.逻辑过期时间为什么能解决缓存击穿问题?逻辑过期指的是什么 其实也没什么多大要改的。海投吧
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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