`

SRM IDNumberVerification

阅读更多
Problem Statement for IDNumberVerification

Problem Statement

    

This problem statement contains superscripts and/or subscripts. These may not display properly outside the applet.

In People's Republic of China, every citizen has a unique ID string. The length of the ID is 18 characters. The first 17 ch

aracters (called the body code) are all digits, the last character (called the checksum code) can be either a digit or 'X'.

The body code is then divided into three parts: from left to right, these are the region code, the birthday code, and the sequential code. They look as follows:

  • The region code has 6 digits. Some 6-digit strings represent regions, other 6-digit strings are invalid. You are given the valid region codes as a String[]regionCodes.
  • The birthday code has 8 digits. It gives the citizen's birthday in the form YYYYMMDD. That is, the first 4 digits is the year of birth, the next 2 is the month (01 to 12, with a leading zero if necessary), and the last 2 digits is the day. When verifying the birthday code, you should consider leap years (see the Notes). Additionally, a valid birthday code must represent a date between Jan 1, 1900 and Dec 31, 2011, inclusive.
  • The sequential code has 3 digits. These 3 digits may be arbitrary, with one exception: the sequential code "000" is invalid. If the sequential code represents an odd number (e.g., "007"), the person is a male. Otherwise (e.g., "420") the person is a female.

The last character of an ID string is the checksum code. This is derived from the first 17 digits. Let a1, a2, ..., a17 denote the body code from left to right. Consider the following modular equation: x + a1*217 + a2*216 + a3*215 + ... + a16*22 + a17*21 = 1 (mod 11). This equation always has exactly one solution x such that 0 <= x <= 10. If x=10, the checksum code is 'X'. Otherwise, the checksum code is the corresponding digit. (E.g., if x=5, the checksum code is '5'.)

You are given a String id. If this is not a valid ID string, return "Invalid" (quotes for clarity). If id represents a valid ID string of a male citizen, return "Male". Finally, if idrepresents a valid ID string of a female citizen, return "Female".

 

Definition

    
Class: IDNumberVerification
Method: verify
Parameters: String, String[]
Returns: String
Method signature: String verify(String id, String[] regionCodes)
(be sure your method is public)
    
 
 

Notes

- A year is a leap year if and only if it satisfies one of the following two conditions: A: It is a multiple of 4, but not a multiple of 100. B: It is a multiple of 400. Therefore, 1904 and 2000 are leap years, while 1900 and 2011 are not.
 

Constraints

- id will be 18 characters long.
- First 17 characters of id will be between '0' and '9', inclusive.
- Last character of id will be 'X' or between '0' and '9', inclusive.
- regionCodes will contain between 1 and 50 elements, inclusive.
- Each element of regionCodes will be 6 characters long.
- Each element of regionCodes will consist of characters between '0' and '9', inclusive.
- For each element of regionCodes, its first character will not be '0'.
- Elements of regionCodes will be pairwise distinct.
 

Examples

0)  
    
"441323200312060636"
{"441323"}
Returns: "Male"
As you can see, region code, birthday code and sequential code are all valid. So we just need to check the equation of checksum code: 6 + 4*217 + 4*216 + 1*215 + 3*214 + 2*213 + 3*212 + 2*211 + 0*210 + 0*29 + 3*28 + 1*27 + 2*26 + 0*25 + 6*24 + 0*23 + 6*22 + 3*21 = 902276. It's easy to verify that 902276 mod 11 = 1. The sequential code ("063") is odd, thus this is a male.
1)  
    
"62012319240507058X"
{"620123"}
Returns: "Female"
 
2)  
    
"321669197204300886"
{"610111","659004"}
Returns: "Invalid"
Region code '321669' is invalid.
3)  
    
"230231198306900162"
{"230231"}
Returns: "Invalid"
Birthday code '19830690' is invalid.
4)  
    
"341400198407260005"
{"341400"}
Returns: "Invalid"
Sequential code '000' is invalid.
5)  
    
"520381193206090891"
{"532922","520381"}
Returns: "Invalid"
Checksum code is incorrect.

 

 

----------------------这题果真是兲朝出的,不过也太简单了点

分享到:
评论

相关推荐

    VMWARE SRM快速部署手册

    ### VMWARE SRM快速部署手册知识点详解 #### 一、准备工作 在开始部署VMware Site Recovery Manager (SRM)之前,需要确保以下几项基础组件已经准备妥当: 1. **vCenter服务器**:作为VMware环境的核心管理平台,...

    HASP-SRM-emulator-D.rar_SRM_SRM emulator_emulator_emulator hasp_

    Driver HASP SRM emulator (x86)

    SRM.zip_SRM_SRM 分析_steganalysis_隐写分析_集成分类器

    SRM空间富模型隐写分析算法,选区高维特征,使用集成分类器进行训练

    SRM-MDM Catalog Setup – Ready Reference

    根据给定的文件信息,我们将深入探讨“SRM-MDM Catalog Setup – Ready Reference”这一主题,专注于SAP NetWeaver MDM系统中的SRM-MDM目录设置过程。这份文档不仅适用于SAP SRM(Supplier Relationship Management...

    SAP-SRM模块快速指南及学习基本知识

    SAP SRM(供应商关系管理)是一种 SAP 产品,有助于通过基于 Web 的平台采购货物。 组织可以采购所有类型的产品,如直接和间接材料,服务,这可以与 SAP ERP 模块和其他非 SAP 后端系统集成,用于会计和计划。 SAP...

    SRM SRM 平台功能介绍.pdf

    SAP SRM 介绍

    HASP SRM加密狗简介

    HASP SRM加密狗简介 HASP SRM加密狗是一种软件保护解决方案,由阿拉丁公司开发。它提供了多种型号,以满足不同业务需要。下面将对HASP SRM加密狗的各种型号进行详细介绍。 首先是HASP HL基本型,这是阿拉丁公司最...

    srm image segmentation code

    《图像分割技术:SRM算法在MATLAB中的实现》 图像分割是计算机视觉领域中的一个核心问题,它旨在将图像划分为多个具有不同特征的区域。在这个领域中,SRM(Statistical Region Merging,统计区域合并)算法因其高效...

    VSAN和SRM.rar

    【标题】"VSAN与SRM"涉及到的是VMware虚拟化环境中的两个关键组件:Virtual SAN(VSAN)和Site Recovery Manager(SRM)。这两个工具在企业级数据中心中发挥着至关重要的作用,确保业务连续性和灾难恢复能力。 VSAN...

    srm后端JAVA 供应商平台管理

    srm后端JAVA 供应商平台管理 标准物资开票表 bus_standard_invoice_out增加freeze_quantity(冻结数量这一列)。 标准物资开票表 bus_standard_invoice_out的主键为{行项目、采购订单号、物料凭证}。 标准物资...

    pe_srm_current_control_SRM_SRMAPC_SRMcontrol_电机_电流环

    标题中的"pe_srm_current_control_SRM_SRMAPC_SRMcontrol_电机_电流环"指出这是一个关于开关磁阻电机(Switched Reluctance Motor, SRM)电流控制的项目,其中涉及了SRM的SRMAPC(Switched Reluctance Motor ...

    SRM系统框架

    多年SRM实施经验总结,对希望从事SRM实施或规划的同学们有帮助

    SRM系统框架图设计

    分块描述SRM系统的作用:寻源、协同和考核 涉及具体的业务用途,供前期规划作参考,可根据实际情况调整,再考虑如何实现

    SRM供应商关系.rar

    《深入理解SRM供应商关系管理》 在现代企业运营中,供应链管理扮演着至关重要的角色。SRM(Supplier Relationship Management)供应商关系管理是这一领域的核心组成部分,它旨在优化企业与供应商之间的互动,提升...

    SAP NetWeaver MDM – SRM Catalog Configuration

    ### SAP NetWeaver MDM – SRM Catalog Configuration #### 概述 本文档旨在总结配置SRM源系统向MDM系统提供产品目录数据的过程,这些数据将发布到SRM买家门户的EBP前端。文档主要通过截图的形式展示了配置步骤,...

    SRM_3D_SRM_开关磁阻电机ansys3d模型_开关磁阻电机_

    开关磁阻电机(Switched Reluctance Motor, SRM)是一种特殊的电动机,其工作原理基于电磁感应,具有结构简单、成本低、效率高等特点。在本资源中,重点是SRM的三维仿真模型,使用了ANSYS Maxwell 3D这一强大的电磁...

    HASP_SRM_Runtime_setup

    HASP_SRM_Runtime_setup

    SAP SRM用途以及功能简介

    SAP SRM用途以及功能简介 SAP SRM(Supplier Relationship Management)是一种旨在改善企业与供应商之间关系的管理思想和软件技术的解决方案。其主要目的是通过与供应商建立长期、紧密的业务关系,并通过对双方资源...

    SRM系统资源管理器

    **SRM系统资源管理器详解** SRM(System Resource Manager)系统资源管理器是一个专为Linux环境设计的工具,它的主要功能是作为一个守护进程在后台持续监控非root用户的进程,以便控制系统的CPU和内存(MEM)资源...

Global site tag (gtag.js) - Google Analytics