ZOJ 3326 An Awful Problem 模拟
只有在 Month 和 Day 都为素数的时候才能得到糖
那就模拟一遍时间即可.
//#pragma comment(linker, "/STACK:16777216") //for c++ Compiler
#include <stdio.h>
#include <iostream>
#include <fstream>
#include <cstring>
#include <cmath>
#include <stack>
#include <string>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <vector>
#include <algorithm>
#define Max(a,b) (((a) > (b)) ? (a) : (b))
#define Min(a,b) (((a) < (b)) ? (a) : (b))
#define Abs(x) (((x) > 0) ? (x) : (-(x)))
#define MOD 1000000007
#define pi acos(-1.0) using namespace std; typedef long long ll ;
typedef unsigned long long ull ;
typedef unsigned int uint ;
typedef unsigned char uchar ; template<class T> inline void checkmin(T &a,T b){if(a>b) a=b;}
template<class T> inline void checkmax(T &a,T b){if(a<b) a=b;} const double eps = 1e- ;
const int N = ;
const int M = * ;
const ll P = 10000000097ll ;
const int MAXN = ; int month1[] = {, , , , , , , , , , , , };
int month2[] = {, , , , , , , , , , , , }; bool run (int x) {
if (x % == && x % != || x % == ) return true;
return false;
} bool prime (int num){
if (num == ) return false;
for (int i = ; i <= sqrt(num); ++i){
if (num % i == ) return false;
}
return true;
} int main() {
std::ios::sync_with_stdio(false);
int i, j, t, k, u, v, numCase = ;
int y1, y2, m1, m2, d1, d2;
cin >> t;
while (t--) {
cin >> y1 >> m1 >> d1 >> y2 >> m2 >> d2;
int ans = ;
while (y1 < y2) {
if (!run (y1)){
for (; m1 <= ; ++m1) {
for (; d1 <= month1[m1]; ++d1){
if (prime(m1) && prime(d1)) ++ans;
}
d1 = ;
}
} else{
for (; m1 <= ; ++m1) {
for (; d1 <= month2[m1]; ++d1) {
if (prime(m1) && prime(d1)) ++ans;
}
d1 = ;
}
}
m1 = ;
++y1;
}
if (!run (y1)) {
for (; m1 < m2; ++m1) {
for (; d1 <= month1[m1]; ++d1) {
if (prime(m1) && prime(d1)) ++ans;
}
d1 = ;
}
for (; d1 <= d2; ++d1) {
if (prime(m2) && prime(d1)) ++ans;
}
} else{
for (; m1 < m2; ++m1) {
for (; d1 <= month2[m1]; ++d1) {
if(prime(m1) && prime(d1)) ++ans;
}
d1 = ;
}
for (; d1 <= d2; ++d1) {
if(prime(m2) && prime(d1)) ++ans;
}
}
cout << ans << endl;
} return ;
}
ZOJ 3326 An Awful Problem 模拟的更多相关文章
- ZOJ 4010  Neighboring Characters(ZOJ Monthly, March 2018 Problem G,字符串匹配)
		
题目链接 ZOJ Monthly, March 2018 Problem G 题意 给定一个字符串.现在求一个下标范围$[0, n - 1]$的$01$序列$f$.$f[x] = 1$表示存在一种 ...
 - ZOJ 4009 And Another Data Structure Problem(ZOJ Monthly, March 2018 Problem F,发现循环节 + 线段树 + 永久标记)
		
题目链接 ZOJ Monthly, March 2018 Problem F 题意很明确 这个模数很奇妙,在$[0, mod)$的所有数满足任意一个数立方$48$次对$mod$取模之后会回到本身. ...
 - ZOJ 2392 The Counting Problem(模拟)
		
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1368 题目大意:计算从S到T中所有的数,其中0,1,2,3,4,5, ...
 - UVALive 3486/zoj 2615 Cells(栈模拟dfs)
		
这道题在LA是挂掉了,不过还好,zoj上也有这道题. 题意:好大一颗树,询问父子关系..考虑最坏的情况,30w层,2000w个点,询问100w次,貌似连dfs一遍都会TLE. 安心啦,这肯定是一道正常 ...
 - hdu_5832_A water problem(模拟)
		
题目链接:hdu_5832_A water problem 这是一个惨痛的教训,想这种这么大的大数肯定就是找个规律模拟一下. 然而我们队还写JAVA,用大数艹了13发罚时,真是TM智障了. #incl ...
 - 详解OJ(Online Judge)中PHP代码的提交方法及要点【举例:ZOJ 1001 (A + B Problem)】
		
详解OJ(Online Judge)中PHP代码的提交方法及要点 Introduction of How to submit PHP code to Online Judge Systems Int ...
 - ZOJ 1457 Prime Ring Problem(dfs+剪枝)
		
 Prime Ring Problem Time Limit: 10 Seconds Memory Limit: 32768 KB A ring is compose of n circ ...
 - 2016中国大学生程序设计竞赛(长春)   Ugly Problem   模拟+大数减法
		
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=5920 我们的思路是: 对于一个串s,先根据s串前一半复制到后一半构成一个回文串, 如果这个回文串比s小, ...
 - ZOJ 1001 A + B Problem
		
熟悉ZOJ环境,如何上传代码,如何查看结果. #include<iostream> using namespace std; int main(){ int a,b; while(cin& ...
 
随机推荐
- [LeetCode]题解(python):121-Best Time to Buy and Sell Stock
			
题目来源: https://leetcode.com/problems/best-time-to-buy-and-sell-stock/ 题意分析: 给定一个数组,代表array[i] 代表第i天的价 ...
 - (Problem 41)Pandigital prime
			
We shall say that an n-digit number is pandigital if it makes use of all the digits 1 to n exactly o ...
 - 什么是weblogic?安装步骤详解
			
weblogic,就是用于java开发的web服务器. tomcat熟悉吧,跟tomcat一个作用,是比tomcat更具优势的web服务器. 安装:(转载) 1.提供安装文件网盘下载:链接处2.安装过 ...
 - WORD 无格式粘贴 2003 2007 MacOS2011
			
2003 打开Word窗口,依次点击“工具----宏----Visual Basic编辑器”,打开“Microsoft visual Basic”窗口,在左侧“工程”栏选中“Normal”工程,点击“ ...
 - Oracle DBA常用的系统表
			
1.2 DBA常用的表1.2.1 dba_开头 dba_users数据库用户信息 dba_segments 表段信息 dba_extents 数据区信息 dba_ob ...
 - mac 下安装和卸载 mysql
			
这里有一篇文章写得很详细: http://www.cnblogs.com/macro-cheng/archive/2011/10/25/mysql-001.html 关于卸载,我也百度了下.找了好几个 ...
 - .net 常用方法
			
1.String数组转换成Int数组 string[] strArr = "a,b,c".Split(','); int[] intArr = Array.ConvertAll& ...
 - 移动Web开发小技巧
			
移动Web开发小技巧 添加到主屏后的标题(IOS) name="apple-mobile-web-app-title" content="标题"> 启用 ...
 - linux命令 收集
			
https://jaywcjlove.github.io/linux-command/ 源码:https://github.com/jaywcjlove/linux-command Linux思维导图 ...
 - BZOJ 1679: [Usaco2005 Jan]Moo Volume 牛的呼声(  )
			
一开始直接 O( n² ) 暴力..结果就 A 了... USACO 数据是有多弱 = = 先sort , 然后自己再YY一下就能想出来...具体看code --------------------- ...