PAT 天梯赛 L1-016. 查验身份证 【水】
2024-08-29 10:01:48
题目链接
https://www.patest.cn/contests/gplt/L1-016
AC代码
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <cstdlib>
#include <ctype.h>
#include <numeric>
#include <sstream>
using namespace std;
typedef long long LL;
const double PI = 3.14159265358979323846264338327;
const double E = 2.718281828459;
const double eps = 1e-6;
const int MAXN = 0x3f3f3f3f;
const int MINN = 0xc0c0c0c0;
const int maxn = 1e5 + 5;
const int MOD = 1e9 + 7;
int vis[] = {7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2};
char c[] = {'1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2'};
bool f(string s)
{
int num = 0;
int len = s.size();
for (int i = 0; i < len - 1; i++)
{
num += (s[i] - '0') * vis[i];
num %= 11;
}
if (s[len - 1] == c[num])
return false;
return true;
}
int main()
{
int n;
cin >> n;
string s;
int flag = 1;
for (int i = 0; i < n; i++)
{
cin >> s;
if (f(s))
{
cout << s << endl;
flag = 0;
}
}
if (flag)
cout << "All passed\n";
}
最新文章
- sql删除前导和后缀
- iOS开发数据库篇—SQLite常用的函数
- .NET向APNS苹果消息推送通知
- CSS padding margin border属性
- win7设置防火墙允许Ping与telnet
- OD: Vulnerability Detection
- 论left-pad的实现
- Uploadify自定义提示信息
- ResultSet遍历过程中修改自身数据,不会改变循环的过程
- Linux下JDK安装
- 对于Java泛型的理解
- Tomcat降权启动
- 利用模板template动态渲染jsp页面
- 同一台电脑同时装Oracle客户端和服务端
- 常用邮箱POP3 STMP服务器与端口号设置
- Python-接口自动化(八)
- 【Mybatis】MyBatis调用带有返回结果、output参数的存储过程上与ibatis的区别
- js的命名空间 &;&; 单体模式 &;&; 变量深拷贝和浅拷贝 &;&; 页面弹窗设计
- VTK中获取STL模型点的坐标以及对其进行变换
- wcf会话、实例化、并发
热门文章
- CI 异步验证
- 我的直播demo
- 与HttpSessionListener接口有关的方法是。
- word中使用MathType能做什么
- 【转载】如何升级linux上的gcc到最新版本
- 将list集合,元素随机打乱
- 如何设置,使IntelliJ IDEA智能提示忽略大小写
- Scala 中我们长见到=>; 解析下
- Drupal 8 提供REST服务实例
- 原!findbugs:NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE 和 OBL_UNSATISFIED_OBLIGATION