poj-2190
来源:互联网 发布:python 弹出消息框 编辑:程序博客网 时间:2024/06/07 05:39
题意:一个ISBN码由10位组成,前9位为数字0~9,第10位为0~9或者X,表示10。ISBN的10位满足,每一位乘以相应系数再求和,求得的和可以被11整除。10位的系数分别为10~1。先给定一个ISBN码,其中一位有缺失,不知其值。请根据上述规则,求缺失的值,或者输出-1表示无解。
#include<fstream>#include<iostream>using namespace std;int main(){ //fstream cin("d:\\test.txt"); string s; int i,v,x,y; while(!cin.eof() && cin>>s) { v=0; for(i=0;i<10;++i) { if(s[i]=='?') { y=i; continue; } if(s[i]=='X') x=10; else x=s[i]-'0'; v+=x*(10-i); } v%=11; if(v==0) cout<<0<<endl; else { v=11-v; y=10-y; while(v%y) v+=11; x=v/y; if(x<10) cout<<x<<endl; else if(x==10 && y==1) cout<<"X"<<endl; else cout<<-1<<endl; } } return 0;}
- poj 2190
- poj-2190
- POJ 2190
- POJ-2190
- poj 2190 ISBN
- POJ 2190ISBN
- poj 2190 ISBN
- POJ 2190 ISBN
- POJ 2190 ISBN
- POJ 2190 模拟
- POJ 2190 ISBN G++
- POJ
- poj
- POJ
- POJ
- poj
- poj
- POJ
- Oracle 冷备份
- mongodb一些基本的数据操作
- Windows2008安装IIS与ftp服务器方法
- C# WinForm实现Win7 Aero磨砂效果
- 为Linux 应用程序编写 DLL
- poj-2190
- 让C#程序自动以管理员方式运行
- Apache 添加BasicAuth
- 纯CSS3时钟
- Qt 无法启动此程序 计算机丢失Qt5Widgetsd.dll....
- 移动医疗
- 母版页
- mysql免安装版配置(检查电脑服务列表里面有没有mysql服务,确认没有)
- C# 调用外部程序Process类