UVA 11947 Cancer or Scorpio 水题
Cancer or Scorpio
Time Limit: 1 Sec Memory Limit: 256 MB
题目连接
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=3098
Description
Alice and Michael is a young couple who are planning on having their first child. Their wish their son Nelson was born on a special date for both of them.
Alice has investigated in the internet and has found that the period of gestation is forty weeks. These forty weeks begin to count on the first day of the last menstrual cycle.
Michael is passionate about astrology and even more about the zodiac signs, he has asked Alice to investigate the range of dates that correspond to each sign.
| Sign | Begin | End |
| Aquarius | January, 21 | February, 19 |
| Pisces | February, 20 | March, 20 |
| Aries | March, 21 | April, 20 |
| Taurus | April, 21 | May, 21 |
| Gemini | May, 22 | June, 21 |
| Cancer | June, 22 | July, 22 |
| Leo | July, 23 | August, 21 |
| Virgo | August, 22 | September, 23 |
| Libra | September, 24 | October, 23 |
| Scorpio | October, 24 | November, 22 |
| Sagittarius | November, 23 | December, 22 |
| Capricorn | December, 23 | January, 20 |
Alice and Michael ask for help to calculate the date of birth of their son Nelson and his zodiac sign.
Input
The first line of input contains a single integer N, ( 1
N
1000) which is the number of datasets that follow.
Each dataset consists of a single line of input that contains only eight digits that represent the date of the first day of the last menstrual cycle in format MMDDYYYY.
Output
For each dataset, you should generate one line of output with the following values: The dataset number as a decimal integer (start counting at one), a space, the date of birth in format MM/DD/YYYY, a space, and the name (in lowercase) of zodiac sign that correspond according to the date of birth.
Note: Considers leap years.
Sample Input
2
01232009
01232008
Sample Output
HINT
题意
啊,有个妹子怀孕了,怀孕40周,然后问你这个孩子什么时候出生,出生后的星座是啥
题解:
啊,这个40周是什么鬼啊,我跑了一下样例,发现应该是271天,于是我就改成271,结果一发就交过了……
这道题真是迷啊
代码:
//qscqesze
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
#include <map>
typedef long long ll;
using namespace std;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
#define maxn 200001
#define mod 10007
#define eps 1e-9
//const int inf=0x7fffffff; //无限大
const int inf=0x3f3f3f3f;
/* */
//**************************************************************************************
inline ll read()
{
int x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
int buf[];
inline void write(int i) {
int p = ;if(i == ) p++;
else while(i) {buf[p++] = i % ;i /= ;}
for(int j = p-; j >=; j--) putchar('' + buf[j]);
printf("\n");
} int month[]={,,,,,,,,,,,,};
int month1[]={,,,,,,,,,,,,};
int check_year(int x)
{
if(x%==)
return ;
if(x%==&&x%!=)
return ;
return ;
}
string check(int x,int y)
{
string ans;
if(x==)
{
if(y<=)
{
ans="capricorn";
return ans;
}
else
{
ans="aquarius";
return ans;
}
}
else if(x==)
{
if(y<=)
{
ans="aquarius";
return ans;
}
else
{
ans="pisces";
return ans;
}
}
else if(x==)
{
if(y<=)
{
ans="pisces";
return ans;
}
else
{
ans="aries";
return ans;
}
}
else if(x==)
{
if(y<=)
{
ans="aries";
return ans;
}
else
{
ans="taurus";
return ans;
}
}
else if(x==)
{
if(y<=)
{
ans="taurus";
return ans;
}
else
{
ans="gemini";
return ans;
}
}
else if(x==)
{
if(y<=)
{
ans="gemini";
return ans;
}
else
{
ans="cancer";
return ans;
}
}
else if(x==)
{
if(y<=)
{
ans="cancer";
return ans;
}
else
{
ans="leo";
return ans;
}
}
else if(x==)
{
if(y<=)
{
ans="leo";
return ans;
}
else
{
ans="virgo";
return ans;
}
}
else if(x==)
{
if(y<=)
{
ans="virgo";
return ans;
}
else
{
ans="libra";
return ans;
}
}
else if(x==)
{
if(y<=)
{
ans="libra";
return ans;
}
else
{
ans="scorpio";
return ans;
}
}
else if(x==)
{
if(y<=)
{
ans="scorpio";
return ans;
}
else
{
ans="sagittarius";
return ans;
}
}
else if(x==)
{
if(y<=)
{
ans="sagittarius";
return ans;
}
else
{
ans="capricorn";
return ans;
}
}
}
int main()
{
int t=read();
for(int cas=;cas<=t;cas++)
{
string s;
cin>>s;
char ch;
int day=,mon=,ye=;
ch=s[];
mon+=ch-'';
ch=s[];
mon=mon*+ch-''; ch=s[];
day+=ch-'';
ch=s[];
day=day*+ch-''; ch=s[];
ye+=ch-'';
ch=s[];
ye=ye*+ch-'';
ch=s[];
ye=ye*+ch-'';
ch=s[];
ye=ye*+ch-''; int now=;
while(now<)
{
now++;
day++;
//cout<<mon<<" "<<day<<" "<<ye<<" "<<now<<endl;
if(check_year(ye))
{
if(day>=month[mon])
{
day=;
mon++;
if(mon>)
{
mon=;
ye++;
}
}
}
else
{
if(day>=month1[mon])
{
day=;
mon++;
if(mon>)
{
mon=;
ye++;
}
}
}
}
if(mon<)
cout<<cas<<""<<mon;
else
cout<<cas<<" "<<mon;
if(day<)
cout<<"/0"<<day<<"/"<<ye<<" "<<check(mon,day)<<endl;
else
cout<<"/"<<day<<"/"<<ye<<" "<<check(mon,day)<<endl;
}
}
UVA 11947 Cancer or Scorpio 水题的更多相关文章
- UVa 11636 Hello World! (水题思维)
题意:给你一个数,让你求需要复制粘贴多少次才能达到这个数. 析:这真是一个水题,相当水,很容易知道每次都翻倍,只要大于等于给定的数就ok了. 代码如下: #include <iostream&g ...
- uva 489 Hangman Judge(水题)
题目:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&am ...
- uva 10252 - Common Permutation 字符串水题
题意:給定兩個小寫的字串a與b,請印出皆出現在兩字串中的字母,出現的字母由a~z的順序印出,若同字母出現不只一次,請重複印出但不能超過任一字串中出現的次數.(from Ruby兔) 很水,直接比较输出 ...
- UVa 10340 - All in All 水题 难度: 0
题目 https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&a ...
- UVA 11100 The Trip, 2007 水题一枚
题目链接:UVA - 11100 题意描述:n个旅行箱,形状相同,尺寸不同,尺寸小的可以放在尺寸大的旅行箱里.现在要求露在最外面的旅行箱的数量最少的同时满足一个旅行箱里放的旅行箱的数量最少.求出这样满 ...
- UVA 11461 - Square Numbers 数学水题
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&p ...
- uva 11059 maximum product(水题)——yhx
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAB1QAAAMcCAIAAABo0QCJAAAgAElEQVR4nOydW7msuhKF2wIasIAHJK
- uva 10976 fractions again(水题)——yhx
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAB3gAAAM+CAIAAAB31EfqAAAgAElEQVR4nOzdO7KtPJum69GEpAcVQQ ...
- UVa 3602 - DNA Consensus String 水题 难度: 0
题目 https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_pr ...
随机推荐
- 大数据系列之分布式计算批处理引擎MapReduce实践
关于MR的工作原理不做过多叙述,本文将对MapReduce的实例WordCount(单词计数程序)做实践,从而理解MapReduce的工作机制. WordCount: 1.应用场景,在大量文件中存储了 ...
- overridePendingTransition()使用
实现两个 Activity 切换时的动画.在Activity中使用有两个参数:进入动画和出去的动画. 注意1.必须在 StartActivity() 或 finish() 之后立即调用.2.而且在 ...
- 原生JS实现AJAX、JSONP及DOM加载完成事件
一.JS原生Ajax ajax:一种请求数据的方式,不需要刷新整个页面:ajax的技术核心是 XMLHttpRequest 对象:ajax 请求过程:创建 XMLHttpRequest 对象.连接服务 ...
- c++中string类中的函数
C/C++ string库(string.h)提供了几个字符串查找函数,如下: memchr 在指定内存里定位给定字符 strchr 在指定字符串里定位给定字符 strcspn 返回在字符串str1里 ...
- mysql慢sql报警系统
前言:最近有同事反应有的接口响应时间时快时慢,经过排查有的数据层响应时间过长,为了加快定位定位慢sql的准确性,决定简单地搭建一个慢sql报警系统 具体流程如下架构图 第一步:记录日志 每个业务系统都 ...
- JS正则表达式方法
使用正则表达式的主要有match,exec,test 1.正则表达式方法test测试给定的字符串是否满足正则表达式,返回值是bool类型的,只有真和假. var user_code = $(" ...
- centos7 PDI(Kettle)安装
kettle介绍 PDI(Kettle)是一种开源的 ETL 解决方案,书中介绍了如何使用PDI来实现数据的剖析.清洗.校验.抽取.转换.加载等各类常见的ETL类工作. 除了ODS/DW类比较大型的应 ...
- Sql Server 添加、更新、查询表注释、字段注释相关sql
/*******************字段添加注释*********************/ if not exists (SELECT C.value AS column_description ...
- 关于《C++ Templates》
最近买了<C++ Templates>来看,书最开始部分阐述了关于此书的一些编程风格.本人感觉非常好,有些地方之前一直容易搞混,这里却讲述的很清楚.例如: 关于下面几种风格的代码: voi ...
- 【LOJ】 #2545. 「JXOI2018」守卫
题解 只会蠢蠢的\(n^3\)--菜啊-- 我们发现最右的端点一定会选,看到的点一定是当前能看到的斜率最小的点变得更小一点,记录下这个点,在我们遇到一个看不到的点的时候,然后只用考虑R到它斜率最小的这 ...