只有在 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 模拟的更多相关文章

  1. ZOJ 4010 Neighboring Characters(ZOJ Monthly, March 2018 Problem G,字符串匹配)

    题目链接  ZOJ Monthly, March 2018 Problem G 题意  给定一个字符串.现在求一个下标范围$[0, n - 1]$的$01$序列$f$.$f[x] = 1$表示存在一种 ...

  2. ZOJ 4009 And Another Data Structure Problem(ZOJ Monthly, March 2018 Problem F,发现循环节 + 线段树 + 永久标记)

    题目链接  ZOJ Monthly, March 2018 Problem F 题意很明确 这个模数很奇妙,在$[0, mod)$的所有数满足任意一个数立方$48$次对$mod$取模之后会回到本身. ...

  3. ZOJ 2392 The Counting Problem(模拟)

    题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1368 题目大意:计算从S到T中所有的数,其中0,1,2,3,4,5, ...

  4. UVALive 3486/zoj 2615 Cells(栈模拟dfs)

    这道题在LA是挂掉了,不过还好,zoj上也有这道题. 题意:好大一颗树,询问父子关系..考虑最坏的情况,30w层,2000w个点,询问100w次,貌似连dfs一遍都会TLE. 安心啦,这肯定是一道正常 ...

  5. hdu_5832_A water problem(模拟)

    题目链接:hdu_5832_A water problem 这是一个惨痛的教训,想这种这么大的大数肯定就是找个规律模拟一下. 然而我们队还写JAVA,用大数艹了13发罚时,真是TM智障了. #incl ...

  6. 详解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 ...

  7. ZOJ 1457 Prime Ring Problem(dfs+剪枝)

     Prime Ring Problem Time Limit: 10 Seconds      Memory Limit: 32768 KB A ring is compose of n circ ...

  8. 2016中国大学生程序设计竞赛(长春) Ugly Problem 模拟+大数减法

    传送门:http://acm.hdu.edu.cn/showproblem.php?pid=5920 我们的思路是: 对于一个串s,先根据s串前一半复制到后一半构成一个回文串, 如果这个回文串比s小, ...

  9. ZOJ 1001 A + B Problem

    熟悉ZOJ环境,如何上传代码,如何查看结果. #include<iostream> using namespace std; int main(){ int a,b; while(cin& ...

随机推荐

  1. 【转】使用Boost Graph library(一)

    转自:http://shanzhizi.blog.51cto.com/5066308/942970 本文是一篇译文,来自:http://blog.csdn.net/jjqtony/article/de ...

  2. JAVA GUI学习 - 总结

    一:项目 二:重要组件补充 三:组件高级操作

  3. Qt Creator needs a compiler set up to build. Configure a compiler in the kit options - Stack Overflow

    Qt Creator needs a compiler set up to build. Configure a compiler in the kit options - Stack Overflo ...

  4. Buffer Cache(缓冲区缓存)篇:缓存区块大小

    缓冲区缓存(Buffer Cache) Buffer Cache是SGA的一部分,保存最近从磁盘读取的或修改的(dml修改或添加)数据块.Buffer Cache的目的就是减少磁盘I/O,提高速度. ...

  5. Color the ball(树状数组+线段树+二分)

    Color the ball Time Limit : 9000/3000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other) Tota ...

  6. Swift:使用系统AVFoundation实现二维码扫描和生成

    系统提供的AVCaptureSession仅仅适用于iOS7.0以上的系统.之前的请用Zbar来替代 下载地址:http://download.csdn.net/detail/huobanbengku ...

  7. DBV-00111: OCI failure (3722) (ORA-01002: fetch out of sequence解决

    在使用DBV检测segment的时候出现 DBV-00111: OCI failure (3722) (ORA-01002: fetch out of sequence)错误: 在寻找原因过程中发现相 ...

  8. cocos2d基础篇笔记四

    1.//有两种集合 //第一种是array 特点:插入,删除效率低,可是查找效率高 //另外一种是list  特点:插入,删除效率高,可是查找效率低 //分析这个游戏: 插入的时候:怪物,射弹出现时, ...

  9. HDU-4866-Shooting(函数式线段树)

    Problem Description In the shooting game, the player can choose to stand in the position of [1, X] t ...

  10. epoll相关

    1) 能不能给一个使用epoll相关API进行IO监控的示例?在<<epoll学习笔记>>中有一个简单的示例说明epoll相关API的使用, 但是这个示例是非常简单的, 它仅仅 ...