能不能过?(C++)
2024-05-10 07:15:11
Description:
Jackie来自江城武汉,一个交通发达,九省通衢的城市。但是由于交通压力,长江二桥以及长江隧道于年初开始施行新的限行方案:禁止当日日期前后两位车牌尾号数字的小型载客汽车通过。例如今天是10月6号,那么尾号是5和7的车将不允许通过。Jackie现在有一些亲戚朋友的车牌号,他想知道今年(2014年)这些车分别有多少天能过桥,你能帮他算出来吗?
Input:
第一行输入一个整数N(0
每组数据输入一个车牌号(如鄂A12345)。
Output:
对于每组数据,输出该车今年能过桥的天数,每行输出对应天数。假设输入的车牌格式合法且均为鄂A开头,且为小型载客汽车,不考虑节假日对政策的影响。
Sample Input:
3
鄂A12345
鄂A67890
鄂A11111
Sample Output:
293
287
294
#include <iostream>
#include "string"using namespace std;/***能不能过?* @param str*/int main() {//尾号为count_*int count_1, count_2, count_3, count_4, count_5, count_6, count_7, count_8, count_9, count_0;//尾号count_*可以通过的天数count_1 = 365 - (6 * 11 + 5);count_2 = 365 - (7 + 6 + 7 + 6 + 7 + 6 + 7 + 7 + 6 + 7 + 6 + 7);count_3 = 365 - (6 * 12);count_4 = 365 - (6 * 12);count_5 = 365 - (6 * 12);count_6 = 365 - (6 * 12);count_7 = 365 - (6 * 12);count_8 = 365 - (6 * 11 + 5);count_9 = 365 - (6 * 11 + 5);count_0 = 365 - (7 + 5 + 7 + 6 + 7 + 6 + 7 + 7 + 6 + 7 + 6 + 7);int t;cin >> t;for (int i = 0; i < t; ++i) {string str;cin >> str;str = str.substr(str.length() - 1, 1);switch (stoi(str)) {case 1:cout << count_1;break;case 2:cout << count_2;break;case 3:cout << count_3;break;case 4:cout << count_4;break;case 5:cout << count_5;break;case 6:cout << count_6;break;case 7:cout << count_7;break;case 8:cout << count_8;break;case 9:cout << count_9;break;case 0:cout << count_0;break;}cout << endl;}
}
最新文章
- 数学知识--Unconstrained Optimization(第二章)
- Java执行main方法,异常为:could not find the main class.program will exit
- NR 5G NG-AP(NG接口)介绍
- 关于系统重装的一件小事
- spring 基本配置学习
- Java06-day06【Debug(概述、操作流程)、Debug查看偶数求和、Debug查看方法调用】
- c库函数-strtol()介绍
- PHP基础3_数组,循环及函数
- 第一章 计算机网络 2 组成与分类 [计算机网络笔记]
- php本机绿色调试,php本地调试工具下载|
- lvds 共模电感_【成功案例】共模电感CM0805C221R-10解决车载LVDS信号的手持天线抗扰问题...
- 控制流图|圈复杂度|基本复杂度
- 微软开源网络攻防模拟工具CyberBattleSim介绍及源码分析
- 哥德巴赫猜想c#语言,哥德巴赫猜想 C#
- DOTA 104个英雄416个技能、104首情诗
- python中sample是什么意思_【后端开发】python中的sample什么意思
- Verilog语言- 和c语言的区别
- 【硬件通信协议】4. 详细解析CAN总线通信协议
- 基于A*搜索算法迷宫游戏开发
- python常见函数sort()对列表元素进行排序