ZOJ 3939 The Lucky Week (暴力找规律)
题意:给定一个幸运日,求第 k 个幸运日是多少。
析:由于闰年,每400肯定会循环一次,所以我们就可以先找出每400年会有多少幸运日,是2058个,然后再暴力。
代码如下:
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <cstring>
#include <set>
#include <queue>
#include <algorithm>
#include <vector>
#include <map>
#include <cctype>
#include <cmath>
#include <stack>
#include <sstream>
#define debug() puts("++++");
#define gcd(a, b) __gcd(a, b)
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define freopenr freopen("in.txt", "r", stdin)
#define freopenw freopen("out.txt", "w", stdout)
using namespace std; typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> P;
const int INF = 0x3f3f3f3f;
const LL LNF = 1e16;
const double inf = 0x3f3f3f3f3f3f;
const double PI = acos(-1.0);
const double eps = 1e-8;
const int maxn = 1e5 + 10;
const int mod = 1e9 + 7;
const int dr[] = {-1, 0, 1, 0};
const int dc[] = {0, 1, 0, -1};
const char *de[] = {"0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111"};
int n, m;
const int mon[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int monn[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
inline bool is_in(int r, int c){
return r >= 0 && r < n && c >= 0 && c < m;
} int whatday(int d, int m, LL y){
if(m == 1 || m == 2) m += 12, --y;
return (d + 2*m + 3*(m+1)/5 + y%7 + y/4%7 - y/100%7 + y/400%7) % 7 + 1;
} int main(){
int T; cin >> T;
while(T--){
int y, m, d, kk;
scanf("%d %d %d %d", &y, &m, &d, &kk);
LL yy = kk / 2058 * 400LL + y;
kk %= 2058;
int ans = 0;
for(LL i = yy; ; ++i){
for(int j = (i == yy) ? m : 1; j < 13; ++j)
for(int k = (i == yy && j == m) ? d : 1; k < 30; k += 10){
if(whatday(k, j, i) == 1) ++ans;
if(ans == kk){
printf("%lld %d %d\n", i, j, k);
goto A;
}
}
}
A:
;
}
return 0;
}
ZOJ 3939 The Lucky Week (暴力找规律)的更多相关文章
- ZOJ 3622 Magic Number 打表找规律
A - Magic Number Time Limit:2000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu Subm ...
- Lucky Conversion(找规律)
Description Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive int ...
- ACM_同余+暴力找规律
小光的忧伤 Time Limit: 2000/1000ms (Java/Others) Problem Description: 锴神:我尊重作者原意,你们出什么我就加什么.于是小光打了道水题(也就是 ...
- ZOJ - 3939 The Lucky Week(日期循环节+思维)
Edward, the headmaster of the Marjar University, is very busy every day and always forgets the date. ...
- Codeforces Round #265 (Div. 2) C 暴力+ 找规律+ 贪心
C. No to Palindromes! time limit per test 1 second memory limit per test 256 megabytes input standar ...
- BZOJ 1002 FJOI 2007 轮状病毒 暴力+找规律+高精度
题目大意: 思路:基尔霍夫矩阵求生成树个数,不会. 可是能够暴力打表.(我才不会说我调试force调试了20分钟... CODE(force.cc): #include <cstdio> ...
- hdu 4708(暴力+找规律)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4708 思路:由于N不大,并且我们可以发现通过旋转得到的4个对角线的点的位置关系,以及所要旋转的最小步数 ...
- hdu 3951 - Coin Game(找规律)
这道题是有规律的博弈题目,,, 所以我们只需要找出规律来就ok了 牛人用sg函数暴力找规律,菜鸟手工模拟以求规律...[牢骚] if(m>=2) { if(n<=m) {first第一口就 ...
- 【poj 2478】Farey Sequence(数论--欧拉函数 找规律求前缀和)
题意:定义 Fn 序列表示一串 <1 的分数,分数为最简分数,且分母 ≤n .问该序列的个数.(2≤N≤10^6) 解法:先暴力找规律(代码见屏蔽处),发现 Fn 序列的个数就是 Φ(1)~Φ( ...
随机推荐
- django 之admin后台管理
数据库 from django.db import models from django.contrib.auth.models import User from django.contrib.aut ...
- 英语发音规则---oo
英语发音规则---oo 一.总结 一句话总结: 1.重读音节词尾的字母组合oo发音素[u:]的音? too [tu:] adv.太;也 zoo [zu:] n.动物园 room [ru:m] n.房间 ...
- R基础之批处理--R IN ACTION
1.5 批处理多数情况下,我们都会交互式地使用R:在提示符后输入命令,接着等待该命令的输出结果.偶尔,我们可能想要以一种重复的.标准化的.无人值守的方式执行某个R程序,例如,你可能需要每个月生成一次相 ...
- Java企业微信开发_02_通讯录同步
一.本节要点 1.获取通讯录密钥 获取方式: 登录企业微信—>管理工具—>通讯录同步助手—>开启“API接口同步” ; 开启后,即可看到通讯录密钥,也可设置通讯录API的权限:读取 ...
- freeMarker(十三)——XML处理指南之揭示XML文档
学习笔记,选自freeMarker中文文档,译自 Email: ddekany at users.sourceforge.net 前言 尽管 FreeMarker 最初被设计用作Web页面的模板引擎, ...
- JEECG datagrid 列表检索条件 添加下拉级联功能
$("#communityId").change( function(){ var id = $(this).children('option:selected').val(); ...
- Operating System-Thread(4) 线程的调度激活机制(Scheduler Activations)
本文主要介绍线程的调度激活机制(Scheduler Activations),主要内容: 调度激活机制简介 上行调用(upcall) 中断处理(Interrupt) 一. 调度激活机制简介 上一篇文章 ...
- docker异常处理
Error running DeleteDevice dm_task_run failed重启docker即可 Error starting daemon: error initializing gr ...
- android开发之Bitmap 、byte[] 、 Drawable之间的相互转换
一.相关概念 1.Drawable就是一个可画的对象,其可能是一张位图(BitmapDrawable),也可能是一个图形(ShapeDrawable),还有可能是一个图层(LayerDrawable) ...
- HDOJ5438(图的各个连通分量遍历)
#include<cstdio> #include<cstring> using namespace std; ; template<class T> struct ...