POJ 2190(模拟策略)
来源:互联网 发布:淘宝抢拍器哪个最好 编辑:程序博客网 时间:2024/06/05 11:54
Language:
ISBN
Time Limit: 1000MS Memory Limit: 65536KTotal Submissions: 13962 Accepted: 4898
Description
ISBN码满足:(10*A1+9*A2+..+1*A10) mod 11=0
A10是效验码,若它为10,则以X代替,其它位都为0..9的数字
现在给你一个效验码,但是其中一位看不清,请求出这一位。
A10是效验码,若它为10,则以X代替,其它位都为0..9的数字
现在给你一个效验码,但是其中一位看不清,请求出这一位。
Input
1行ISBN码,‘?'表示看不清
Output
输出那一位,无解输-1.
Sample Input
15688?111X
Sample Output
1
Source
USACO 2003 Fall Orange
这题就是模拟,模拟最重要的是细节,本题值得注意的细节:
1.某1位为0的情况.
2.其它位的乘积和是11的倍数.
3.某1位为X的情况.
4.无解.
5.其它位的乘积和包含'X'.
Program ISBN;const n=10; F=11;var s:string; i,p,ans:longint;begin ans:=0; readln(s); if s[n]='X' then s[n]:=char(58); p:=pos('?',s); for i:=1 to n do if i<>p then inc(ans,(ord(s[i])-48)*(10-i+1)); // ans +p*? mod 11 =0 ans:=ans mod F; ans:=(F-ans) mod F; for i:=0 to n do begin if ((11-p)*i) mod F=ans then begin if (p=n) and (i=10) then begin writeln('X'); halt; end; if (i<10) then begin writeln(i); halt; end; end; end; writeln('-1');end.
- POJ 2190(模拟策略)
- poj 2190 简单模拟(ISBN)
- POJ 2190 模拟
- poj 3325(模拟)
- POJ 1008(模拟)
- poj 2632 (模拟)
- POJ 1068(模拟)
- POJ 3087(模拟)
- poj 3087 (模拟)
- POJ 1008 (模拟)
- poj 2745显示器(模拟)
- poj 1068 Parencodings(模拟)
- poj 1597(水模拟)
- poj 1068 Parencodings(模拟)
- poj 1068 Parencodings(模拟)
- POJ 1017 Packets(模拟)
- poj Robot Motion(模拟)
- poj 1068 Parencodings(模拟)
- 转 Ant builder.xml 详解
- js操作Excel
- 程序员应当如何保持优秀
- GUI 剖析之图片显示
- 关于CI分页的心得
- POJ 2190(模拟策略)
- oracle数据类型
- C复习
- 以System启动进程
- 百度地图上画出轨迹 for android
- iOS的基本设计模式
- xPath对xml文档的处理入门4
- 基于注解的SpringMVC
- 架构设计之CS架构