swustoj---寝室扫地问题509

计算特定日期是否为大扫除日及归属清扫者
本文介绍了一种算法,通过计算给定日期的总天数并进行模运算,来判断该日期是否为大扫除日,并确定当天负责清扫的人。

这道题不难,计算好总天数然后对7取余数看看是不是3就知道是不是大扫除那天。如果不是大扫除直接减去大扫除的天数再对4取模就知道该谁扫地了。


#include <stdio.h>
int main()
{
   int m[12]={31,28,31,30,31,30,31,31,30,31,30,31};
   int year,month,day;
   int i;
   while(scanf("%d %d %d",&year,&month,&day)!=EOF)
   {
       for(i = 0;i < month-1;i++)
           day+=m[i];
       day = day+(year-2007)*365-243;//计算总天数
       if((year==2008&&month>2)||year>2008)
           day++;
       if(day%7==3)
       {
           printf("ALL\n");
           continue;
       }
       int sum =(day-day/7);//减去all的天数
       if(day%7>=3)//如果大于了3则有一天all没有计算到。
           sum--;
       switch(sum%4)
       {
         case 1:printf("B\n");break;
         case 2:printf("X\n");break;
         case 3:printf("H\n");break;
         case 0:printf("P\n");break;
       }
   }
   return 0;
}

### SWUST OJ Problem 32 Information and Solution Unfortunately, specific details about SWUST OJ problem number 32 are not directly provided in the available references. However, based on similar problems from this platform such as those mentioned in other citations, a general approach to solving typical programming challenges can be outlined. #### Understanding Common Elements of Programming Problems on SWUST OJ Platform Problems like SWUSTOJ276, SWUSTOJ77, SWUSTOJ78, SWUSTOJ1286, and SWUSTOJ1285 emphasize proper use of `if` and `else` statements along with maintaining good coding practices including appropriate formatting[^1]. For instance, when dealing with numerical outputs, `%g` is used for automatic selection between fixed-point notation (`%f`) or scientific notation (`%e`), depending on which provides more compact output without loss of precision. Given that detailed specifics regarding problem 32 aren't present here, one should look at common patterns found across different types of questions posed by platforms like these: - **Input Handling**: Typically involves reading inputs either single values or arrays/lists. - **Logic Implementation**: Applying algorithms ranging from simple arithmetic operations up through complex data structures manipulation. - **Output Formatting**: Ensuring results adhere strictly to specified formats using placeholders like `%d`, `%s`, etc., where applicable. Since no direct reference exists specifically addressing SWUST OJ problem 32 within given sources, consider exploring adjacent numbered problems around it for clues about its nature—whether mathematical computation, string processing, dynamic programming elements, et cetera—and adapt solutions accordingly while keeping best practice guidelines intact. ```c // Example C code snippet demonstrating basic structure often seen in contest-style programs #include <stdio.h> int main() { int n; scanf("%d", &n); // Read input value if (condition_based_on_problem_statement) { printf("Result under condition A\n"); } else { printf("Alternative result\n"); } return 0; } ``` --related questions-- 1. How does understanding how `%g` works help improve program efficiency? 2. What strategies could apply towards optimizing performance in competitive programming contests? 3. Can you provide examples illustrating effective usage of conditional operators (`if`, `else`) in algorithm design?
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值