当前位置:网站首页>Redraiment的遭遇
Redraiment的遭遇
2022-07-17 05:21:00 【winkiii】
描述
Redraiment的老家住在工业区,日耗电量非常大。是政府的眼中钉肉中刺,但又没办法,这里头住的可都是纳税大户呀。 今年7月,又传来了不幸的消息,政府要在7、8月对该区进行拉闸限电。但迫于压力,限电制度规则不会太抠门,政府决定从7月1日停电,然后隔一天到7月3日再停电,再隔两天到7月6日停电,一次下去,每次都比上一次晚一天。 Redraiment可是软件专业的学生,怎么离得开计算机。如果停电,就“英雄无用武之地”了。呵呵。 所以他开始盘算起自己回家的日子了,他想知道自己到家后到底要经历多少天倒霉的停电。你能帮他算一算吗?
输入
输入包括多组数据。 每组数据包括一行:redraiment到家的日期。 输入以0/0结束。
输出
对应每个输入包括一个输出。
为redraiment回家后停电的天数(包括到家那天)。
输入样例 1
8/31
0/0
输出样例 1
0
#include<stdio.h>
int main(){
int m,d;
int day[63]; //注意数组界限
int i=1,t=1,j;
for(j=1;j<=62;j++){
//七八月每一天统一置为1
day[j] = 1;
}
while(i<=62){
//将停电当天置为0
day[i] = 0;
t++;
i+=t;
}
while(scanf("%d/%d",&m,&d)){
if(m==0&&d==0) break;
int td = 0; //已经过去的停电天数
if(m==7){
int k;
for(k=1;k<d;k++){
if(day[k]==0){
td++;
}
}
}
else if(m==8){
td = 7; //七月一共停电7天
int k;
for(k=1;k<d;k++){
if(day[k+31]==0){
//八月下标需加上31
td++;
}
}
}
else{
//除七、八月其他月份停电情况不考虑,暂认为都不停电
td = 10;
}
printf("%d\n",10-td);
}
}
边栏推荐
- Some problems encountered in work
- STM32 serial communication related learning
- Generate audio and waveform in PWM and DAC exercises of stm32
- [jmeter] TCP Sampler
- Application case of CS brand sdnand in color detector industry
- Huawei routing port mapping
- 剑指offer刷题
- 《PyTorch深度学习实践》-B站 刘二大人-day6
- 【自动化测试】——robotframework实战(三)编写测试用例
- Common user password encryption methods and cracking methods
猜你喜欢

《PyTorch深度学习实践》-B站 刘二大人-day3

Binary search and its extension

伺服电机的电子齿轮比如何确定?

Wu Enda machine learning chapter 8-9

top命令

Hand in hand building a home NAS universal server (1) | configuration selection and preparation

Temperature acquisition experiment and experimental experience based on I2C

Generate audio and waveform in PWM and DAC exercises of stm32

Network layer and IP learning

Arabic numerals to Chinese
随机推荐
Pytorch deep learning practice-b station Liu erden-day6
Common user password encryption methods and cracking methods
STM32的PWM和DAC练习中生成音频和波形
Experiment class II and object definition initialization
Experiment 3 inheritance and derived classes
华为路由 端口映射
通过数据加密方案阻止勒索攻击
lock
libevent 报 undefined reference to `getrandom‘
Arabic numerals to Chinese
Experiment 4 operator overloading and virtual functions
sql的约束条件
BigDecimal中divide方法
day01(Flume)
促进数字世界的信任
tail -f暂停方法
Slag learning path (1) output the calendar page of a certain month of a certain year
5-17 hidden student services of Shaanxi University of science and technology
二分查找及其引申
Application of views and index files