博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ZOJ Problem Set - 3326 An Awful Problem(模拟题,待改正)
阅读量:4036 次
发布时间:2019-05-24

本文共 3369 字,大约阅读时间需要 11 分钟。

1、

2.、题目

An Awful Problem

           


           

               
Time Limit: 1 Second                                   
Memory Limit: 32768 KB                           

           


           

In order to encourage Hiqivenfin to study math, his mother gave him a sweet candy when the day of the month was a prime number.Hiqivenfin was happy with that.But several days later, his mother modified the rule so that he could get a candy only when the day of the month was a prime number and the month was also a prime number.He felt a bit upset because he could get fewer candies.What's worse, his mother changed the rule again and he had to answer a question before he could get a candy in those days.The question was that how many candies he could get in the given time interval.Hiqivenfin wanted to cry and asked you for help.He promised to give you half of a candy if you could help him to solve this problem.

Input

There are multiple test cases.The first line of input is an integer T (0 < T <= 50), indicating the number of test cases. Then T test cases follow. The i-th line of the next T lines contains two dates, the day interval of the question. The format of the date is "yyyy mm dd". You can assume both dates are valid. Hiqivenfin was born at 1000-01-01 and would not die after 2999-12-31, so the queries are all in this interval.

Hiqivenfin didn't seem to be an earthman, but the calendar was the same as that we usually use.That is to say, you need to identify leap years, where February has 29 days. In the Gregorian calendar, leap years occur in years exactly divisible by four. So, 1993, 1994, and 1995 are not leap years, while 1992 and 1996 are leap years. Additionally, the years ending with 00 are leap years only if they are divisible by 400. So, 1700, 1800, 1900, 2100, and 2200 are not leap years, while 1600, 2000, and 2400 are leap years.

Output

Output the number of candies Hiqivenfin could get in the time interval. Both sides of the interval are inclusive.

Sample Input

21000 01 01 1000 01 312000 02 01 2000 03 01

Sample Output

010

 

3、wrong 代码

#include
#include
#include
using namespace std;int m[12]= {0,0,11,0,11,0,11,0,0,0,10,0};int f[31]= {0,1,1,0,1,0,1,0,0,0,1,0,1,0,0,0,1,0,1,0,0,0,1,0,0,0,0,0,1,0,1};int leap(int y){ if((y%400==0) ||(y%4==0 && y%100!=0)) return 1; return 0;}int main(){ int t,y1,y2,m1,m2,d1,d2; while(scanf("%d",&t)!=EOF) { while(t--) { scanf("%d%d%d",&y1,&m1,&d1); scanf("%d%d%d",&y2,&m2,&d2); if(y1>y2 || (y1==y2 && m1>m2) || (y1==y2 && m1==m2 && d1>d2)) { int a=y1,b=m1,c=d1; y1=y2,m1=m2,d1=d2; y2=a,m2=b,d2=c; } int len=y2-y1; int sum=0; //不在同一年 if(len>0) { //处理年 for(int i=y1+1; i
=2) { if(leap(y2)) sum+=10; else sum+=9; } //处理日 if(m1==2 || m1==3 || m1==5 || m1==7 || m1==11) { for(int i=1; i
=2) { if(leap(y1)) sum+=10; else sum+=9; } //处理日 if(m1==2 || m1==3 || m1==5 || m1==7 || m1==11) { for(int i=1; i

 

转载地址:http://oeddi.baihongyu.com/

你可能感兴趣的文章
Idea导入的工程看不到src等代码
查看>>
技术栈
查看>>
Jenkins中shell-script执行报错sh: line 2: npm: command not found
查看>>
8.X版本的node打包时,gulp命令报错 require.extensions.hasownproperty
查看>>
Jenkins 启动命令
查看>>
Maven项目版本继承 – 我必须指定父版本?
查看>>
Maven跳过单元测试的两种方式
查看>>
通过C++反射实现C++与任意脚本(lua、js等)的交互(二)
查看>>
利用清华镜像站解决pip超时问题
查看>>
[leetcode BY python]1两数之和
查看>>
微信小程序开发全线记录
查看>>
Centos import torchvision 出现 No module named ‘_lzma‘
查看>>
PTA:一元多项式的加乘运算
查看>>
CCF 分蛋糕
查看>>
解决python2.7中UnicodeEncodeError
查看>>
小谈python 输出
查看>>
Django objects.all()、objects.get()与objects.filter()之间的区别介绍
查看>>
python:如何将excel文件转化成CSV格式
查看>>
Django 的Error: [Errno 10013]错误
查看>>
机器学习实战之决策树(一)
查看>>